
                1    **********************************************************
                2    *                                                        *
                3    *                 N A D A . P R O D O S                  *
                4    *                                                        *
                5    *               ProDOS version of NadaNet                *
                6    *                                                        *
                7    *           Michael J. Mahon - April 14, 1996            *
                8    *                 Revised Nov 17, 2004                   *
                9    *                                                        *
                10   *             Copyright (c) 1996, 2003, 2004             *
                11   *                                                        *
                12   *   NadaNet is a suite of 6502 machine code routines     *
                13   *   to support bidirectional communication among several *
                14   *   Apple // computers over a single pair of wires which *
                15   *   are connected to the game ports of the machines.     *
                16   *                                                        *
                17   *   An annunciator output is used to "broadcast" to all  *
                18   *   machines, and a "pushbutton" input is used to sense  *
                19   *   the state of the shared signalling wire.  This is    *
                20   *   similar to Ethernet, but at lower speed and at TTL   *
                21   *   levels.                                              *
                22   *                                                        *
                23   *   The raw signaling speed is 1 bit every 9 cycles, or  *
                24   *   113.3 kilobaud.  With byte separator overhead of 30  *
                25   *   cycles, this translates to 1 byte every 106 cycles,  *
                26   *   or almost 10K bytes/sec.                             *
                27   *                                                        *
                28   *   All signal transmission and reception is done with   *
                29   *   carefully timed software routines.  Synchronization  *
                30   *   is assured by a digital PLL at the receiver which    *
                31   *   adapts to variations in timing of +/- 2 cycles/byte. *
                32   *   (If a machine has a Zip Chip accelerator installed,  *
                33   *   it will be temporarily slowed during packet trans-   *
                34   *   mission and reception.)                              *
                35   *                                                        *
                36   **********************************************************
                37   
                38   ******************** Version setup ***********************
                39   
                40   SIZE     equ   $900       ; "Do not exceed" size
                41   
                42            org   $9A00-SIZE ; 'NADANET' for ProDOS hosts
                43   master   equ   1          ; Compile master-only functions
                44   dos      equ   0          ; Non-DOS version
                45   crate    equ   0          ; Non-Crate version
                46   mserve   equ   0          ; Non-Message Server version
                47   ROMboot  equ   0          ; Non-ROM version
 
                ===== Page 2 -  NADA.PRODOS - Nov. 17, 2004 =====
  
                49           put   NADAHIST   
               >1    **********************************************************
               >2    *                                                        *
               >3    *                    Change History                      *
               >4    *                                                        *
               >5    *   11/17/04:                                            *
               >6    *                                                        *
               >7    *   Changed 'servegap' wait time to 3/4 of min arb time  *
               >8    *   to allow some margin for server routine processing   *
               >9    *   after network is released (which is subtracted from  *
               >10   *   "SERVER visible" inter-request gap).                 *
               >11   *                                                        *
               >12   *   11/13/04                                             *
               >13   *                                                        *
               >14   *   Changed AmperNada handler to leave return variable   *
               >15   *   unchanged when an error occurs.                      *
               >16   *                                                        *
               >17   *   11/12/04:                                            *
               >18   *                                                        *
               >19   *   Increased BPOKE locked wait time to 20ms. to allow   *
               >20   *   more "dead time" in an Applesoft &SERVE polling loop.*
               >21   *                                                        *
               >22   *   11/10/04:                                            *
               >23   *                                                        *
               >24   *   Changed SERVER gap wait to wait for an unchanging    *
               >25   *   net, not an idle net, so that a BPOKE is received    *
               >26   *   when preceded by a locked state.                     *
               >27   *                                                        *
               >28   *   Fixed bug in PKINCSRV that dropped carry.            *
               >29   *                                                        *
               >30   *   11/08/04:                                            *
               >31   *                                                        *
               >32   *   Changed AmperNada handler to throw an Applesoft      *
               >33   *   "DATA" (49) error by default when a command fails.   *
               >34   *   This error can be caught by an active ONERR, or it   *
               >35   *   can be suppressed by appending a "#" to the command. *
               >36   *   If the error is suppressed, it is the programmer's   *
               >37   *   responsibility to check status by PEEKing 1 and 0.   *
               >38   *                                                        *
               >39   *   11/06/04:                                            *
               >40   *                                                        *
               >41   *   Removed &ONERR(err?) because its residual effects--  *
               >42   *   storing status into variable memory--outlast any     *
               >43   *   running program unless explicitly cancelled.  Using  *
               >44   *   PEEK(1) is a safe and effective alternative solution.*
               >45   *                                                        *
               >46   *   11/05/04:                                            *
               >47   *                                                        *
               >48   *   Added BPOKE & PEEKINC requestors and servers.        *
               >49   *                                                        *
               >50   *   Added &IDTBL(val?) to retrieve address of 'idtable'  *
               >51   *   in 'master' version.                                 *
               >52   *                                                        *
               >53   *   Changed ARBTRATE to use a single loop, and SETID to  *
               >54   *   use ID for 'arbxv' when a temp ID (>$7F) is used.    *
               >55   *                                                        *
               >56   *   11/01/04:                                            *
               >57   *                                                        *
               >58   *   Integrated AmperNada ampersand interface for BASIC   *
               >59   *   into NadaNet.  Size limit is now $900.               *
               >60   *                                                        *
               >61   *   10/27/04:                                            *
               >62   *                                                        *
               >63   *   Fixed latent BOOT timing bug in server.              *
               >64   *                                                        *
               >65   *   Changed SERVER so that it returns after processing   *
               >66   *   any request, in addition to when a key is pressed.   *
               >67   *                                                        *
               >68   *   Changed SERVER and CALLSRV to do indirect jumps,     *
               >69   *   rather than pushing addresses on stack for rts.      *
 
                ===== Page 3 -  NADA.PRODOS - Nov. 17, 2004 =====
 
               >70   *                                                        *
               >71   *   Changed REQUEST resend count so that the request     *
               >72   *   timeout set by 'reqtime' is accurate.                *
               >73   *                                                        *
               >74   *   Changed MONITOR to wait for a minimum period of      *
               >75   *   unchanging network state, rather than '0' state, so  *
               >76   *   a locked state between packets is detected as a gap. *
               >77   *                                                        *
               >78   *   10/20/04:                                            *
               >79   *                                                        *
               >80   *   Added changes so that NADABOOT could be built using  *
               >81   *   standard NADANET "put" files.                        *
               >82   *                                                        *
               >83   *   Split this change history into a separate file.      *
               >84   *                                                        *
               >85   *   10/18/04:                                            *
               >86   *                                                        *
               >87   *   Added code to INIT to set up $3CD with warm start    *
               >88   *   'JMP servelp', so $3CF is NADANET's load page.       *
               >89   *                                                        *
               >90   *   10/13/04:                                            *
               >91   *                                                        *
               >92   *   Made PUTMREQ and GETMREQ conditional upon 'master'   *
               >93   *   conditional compile flag.  PUTMSRV and GETMSRV are   *
               >94   *   conditional upon 'not master'.  This frees up space  *
               >95   *   for additional enhancements by splitting NadaNet into*
               >96   *   different functional subsets for different purposes. *
               >97   *                                                        *
               >98   *   Made RCVPKT timeout variable so it can be set to the *
               >99   *   minimum arbitration time while within a protocol,    *
               >100  *   to protect the protocol from "outside" interference, *
               >101  *   and set to 20ms. outside a protocol, when SERVE or   *
               >102  *   MONITOR is running, to reduce polling dead time.     *
               >103  *                                                        *
               >104  *   Moved packet-starting 'ONE' earlier in SENDPKT so    *
               >105  *   that ARBTRATE and RCVPKT do not need to double-poll  *
               >106  *   bus to detect start pulse.                           *
               >107  *                                                        *
               >108  *   Changed BOOTREQ to use boot code address, length,    *
               >109  *   and local address set up prior to SERVER call.       *
               >110  *                                                        *
               >111  *   Split entry point vector and variable definitions    *
               >112  *   out into NADADEFS "put" file for use in other progs. *
               >113  *                                                        *
               >114  *   10/05/04:                                            *
               >115  *                                                        *
               >116  *   Changed ARBTRATE to lock the bus after a successful  *
               >117  *   poll, so that the arbitration "increment" could be   *
               >118  *   reduced to 22 cycles from 66.                        *
               >119  *                                                        *
               >120  *   Changed SETID arbitration time calculation to match. *
               >121  *                                                        *
               >122  *   Changed SERVER so that received requests, whether    *
               >123  *   acted upon or not, are counted as 1/8 of a 20ms.     *
               >124  *   timeout interval.  This allows time-related events   *
               >125  *   to occur properly whether the net is busy or idle.   *
               >126  *                                                        *
               >127  *   Moved 'sbuf', 'rbuf', and counters so that they will *
               >128  *   move less in the future.                             *
               >129  *                                                        *
               >130  *   Made REQUEST retry limit an initialized variable so  *
               >131  *   that it can be lowered to speed up detection of a    *
               >132  *   possibly non-existent machine.                       *
               >133  *                                                        *
               >134  *   Moved the 'monch' table used by PUTMSRV and GETMSRV  *
               >135  *   from internal memory to the unused top of the page   *
               >136  *   map table, saving 48 bytes of program memory.        *
               >137  *                                                        *
               >138  *   06/23/04:                                            *
               >139  *                                                        *
 
                ===== Page 4 -  NADA.PRODOS - Nov. 17, 2004 =====
 
               >140  *   Added iteration counter to SERVER and dispensed with *
               >141  *   SERVE1.  Changed SERVE sync wait to min arbitration  *
               >142  *   time.                                                *
               >143  *                                                        *
               >144  *   Disabled interrupts during SENDPKT and RCVPKT.       *
               >145  *                                                        *
               >146  *   Made "packet"/"message" nomenclature consistent.     *
               >147  *                                                        *
               >148  *   Disabled interrupts in SENDPKT and RCVPKT.           *
               >149  *                                                        *
               >150  *   06/04/04:                                            *
               >151  *                                                        *
               >152  *   Made INIT, SERVE, and BOOT functions and PEEK, POKE, *
               >153  *   and CALL functions separate include modules.         *
               >154  *                                                        *
               >155  *   Added text graphics for protocols.                   *
               >156  *                                                        *
               >157  *   05/26/04                                             *
               >158  *                                                        *
               >159  *   Added MONITOR function for snooping all packets on   *
               >160  *   the network and logging the first 8 bytes in memory. *
               >161  *                                                        *
               >162  *   05/15/04:                                            *
               >163  *                                                        *
               >164  *   Added "master" conditional assembly switch to        *
               >165  *   control newly added  boot functions, BOOTREQ and     *
               >166  *   GETIDSRV.                                            *
               >167  *                                                        *
               >168  *   05/06/04:                                            *
               >169  *                                                        *
               >170  *   Shortened arbitration time to 1 ms., since almost    *
               >171  *   all protocols have less than 1 ms. delay between     *
               >172  *   packets.  Exceptions will "lock" the net by pulling  *
               >173  *   it high until they can respond.  This is effectively *
               >174  *   an extended "start" pulse, and RCVPKT will wait      *
               >175  *   indefinitely for the transition to low.              *
               >176  *                                                        *
               >177  *   Currently, only PUTMSRV and GETMSRV can take longer  *
               >178  *   than 1 ms. to respond with ACK or NAK, so they must  *
               >179  *   lock the net until their response.                   *
               >180  *                                                        *
               >181  *   The delay from last arbitration poll until beginning *
               >182  *   of "start" pulse is 54 cycles, so to avoid collision *
               >183  *   the arbitration delay difference between machines    *
               >184  *   must exceed 54.  Since it must be a multiple of 11   *
               >185  *   cycles, the offset is machine ID * 66 cycles.        *
               >186  *                                                        *
               >187  *   Since 8-byte data packets are indistinguishable      *
               >188  *   from control packets, and since data packets are     *
               >189  *   never delayed from a preceding control packet by     *
               >190  *   more than 0.5 ms., SERVER must wait for a net "idle" *
               >191  *   (low) state for 0.5 ms. to ensure that the next pkt  *
               >192  *   it receives is not data.  This delay is only needed  *
               >193  *   if the net has not been polled for more than the     *
               >194  *   arbitration delay (~1 ms.).                          *
               >195  *                                                        *
               >196  *   04/19/04:                                            *
               >197  *                                                        *
               >198  *   Changed RCVPKT timeout to 20 ms., since responses    *
               >199  *   are expected in much less.  SERVER loop results in   *
               >200  *   "blind" time of less than 0.04 ms. per iteration.    *
               >201  *                                                        *
               >202  *   Changed CALLSRV to pass parameters A and X passed    *
               >203  *   in 'rbuf+len' bytes.                                 *
               >204  *                                                        *
               >205  *   Factored RCVDACK code out for general use.           *
               >206  *                                                        *
               >207  *   Changed REQUEST to return on ACK or NAK response.    *
               >208  *                                                        *
               >209  *   03/05/04:                                            *
 
                ===== Page 5 -  NADA.PRODOS - Nov. 17, 2004 =====
 
               >210  *                                                        *
               >211  *   Changed code to avoid address modification (to allow *
               >212  *   code to run in ROM).  This adds one cycle/byte.      *
               >213  *                                                        *
               >214  *   Changed RCVPKT digital PLL back to +/- 2 cycles/byte *
               >215  *   because of page crossing variances in SENDPKT and    *
               >216  *   RCVPKT LDA and STA ops that had been overlooked.     *
               >217  *                                                        *
               >218  *   09/04/03:                                            *
               >219  *                                                        *
               >220  *   Changed SENDPKT and RCVPKT to new bit timing by      *
               >221  *   unrolling loops.                                     *
               >222  *                                                        *
               >223  *   Changed RCVPKT digital PLL to be +/- 1 cycle/byte    *
               >224  *   instead of +/- 2 cycles/byte to tighten tolerances.  *
               >225  *                                                        *
               >226  **********************************************************
 
                ===== Page 6 -  NADA.PRODOS - Nov. 17, 2004 =====
  
                50           put   NADACONST  
               >1    * Constant definitions
               >2    
               >3    px       equ   $FF        ; Constant to force page x-ing
               >4    cyperms  equ   1020       ; Cycles per ms. (really 1020.4)
               >5    
               >6    * Protocol constants
               >7    
               >8    arbtime  equ   1          ; Min arbitration time (ms)
               >9    ]cy      equ   arbtime*cyperms ; Arbtime in cycles
               >10   ]cpx     equ   11         ; Cycles per X iteration
               >11   arbx     equ   ]cy/]cpx   ; X iterations
               >12   
               >13   ]servpad equ   ]cy/4      ; Gap margin
               >14   servegap equ   ]cy-]servpad/13 ; SERVER wait loop 13 cyc.
               >15   
               >16   ]cy      equ   ]cpx*256   ; Max arb time (cycles)
               >17   maxarb   equ   ]cy+cyperms/cyperms ; ceiling(max arb) (ms)
               >18   
               >19   idletime equ   20         ; Idle polling timeout (ms.)
               >20                             ; (stay under 51ms for Zip Chip)
               >21   ]cy      equ   idletime*cyperms ; Timeout in cycles
               >22   ]cpx     equ   11         ; Cycles per X iteration
               >23   ]cpy     equ   ]cpx*256+4 ; Cycles per Y iteration
               >24   idleto   equ   ]cy/]cpy+1 ; Number of Y iterations
               >25   
               >26   reqto    equ   1          ; Timeout within protocol is
               >27                             ;  minimum arbitration time.
               >28   
               >29   maxgap   equ   101        ; Max intra-pkt gap (cycles)
               >30   gapwait  equ   maxgap/13+1 ; MONITOR wait loop is 13 cyc.
               >31   
               >32   reqtime  equ   3000       ; Req response timeout (ms.)
               >33   rqperiod equ   20         ; Milliseconds between retrys
               >34   reqdelay equ   rqperiod-3 ; ARB+SEND+RCV timeout = 3ms.
               >35   
               >36   maxreqrt equ   3          ; Max # of xxxREQ retries
               >37   maxretry equ   reqtime/rqperiod/maxreqrt ; # of re-sends
               >38   
               >39   bootdly  equ   1000       ; Time (ms) to delay after
               >40                             ;  GETID before broadcasting
               >41                             ;   BOOT request and code.
               >42   bootcnt  equ   bootdly/idletime ; SERVER timeout count
 
                ===== Page 7 -  NADA.PRODOS - Nov. 17, 2004 =====
  
               >44   * Apple ][ definitions
               >45   
               >46   an       equ   $C058      ; Annunciator 0 base addr
               >47   an0      equ   an         
               >48   an1      equ   an+2       
               >49   an2      equ   an+4       
               >50   an3      equ   an+6       
               >51   
               >52   pb       equ   $C061      ; "Pushbutton" 0 base addr
               >53   pb0      equ   pb         
               >54   pb1      equ   pb+1       
               >55   pb2      equ   pb+2       
               >56   
               >57   keybd    equ   $C000      ; Keyboard port
               >58   VBL      equ   $C019      ; Vertical blanking
               >59   spkr     equ   $C030      ; Speaker toggle
               >60   ptrig    equ   $C070      ; Paddle trigger
               >61   
               >62   dsk6off  equ   $C0E8      ; Deselect 5.25" disk in slot 6
               >63   
               >64   SOFTEV   equ   $3F2       ; Soft re-entry vector
               >65   PWREDUP  equ   $3F4       ; Powered-Up check byte
               >66   
               >67   * Mapping of hardware resources
               >68   
               >69   dsend    equ   an1        ; Data 'send'
               >70   drecv    equ   pb1        ; Data 'receive'
               >71   zipslow  equ   dsk6off    ; Zip Chip 'slow mode' for 51 ms.
               >72   
               >73   * Page zero variables
               >74   
               >75   leng     equ   $EB        ; Length: 1..256 (0 ==> 256)
               >76   ckbyte   equ   $EC        ; Check byte
               >77   ptr      equ   $ED        ; Data buffer pointer (0..leng-1)
               >78   address  equ   $FC        ; Scratch addr of local data
               >79   length   equ   $FE        ; Scratch length of local data
 
                ===== Page 8 -  NADA.PRODOS - Nov. 17, 2004 =====
  
                51           use   NADAMACS   
               >1    ***************** Macro definitions ********************
               >2    
               >3    inc16    mac              
               >4             inc   ]1         ; Increment 16-bit word.
               >5             do    ]1+1/$100  ; If ]1 is non-page zero
               >6             bne   *+5        ; - No carry.
               >7             else             ; Else if ]1 on page zero
               >8             bne   *+4        ; - No carry.
               >9             fin              
               >10            inc   ]1+1       ; Propagate carry.
               >11            eom              
               >12   
               >13   mov16    mac              
               >14            lda   ]1         ; Move 2 bytes
               >15            sta   ]2         
               >16            if    #=]1
               >17            lda   ]1/$100    ; high byte of immediate
               >18            else             
               >19            lda   1+]1       
               >20            fin              
               >21            sta   1+]2       
               >22            eom              
               >23   
               >24   delay    mac              
               >25            ldx   #]1/5      ; (5 cycles per iteration)
               >26   ]delay   dex              
               >27            bne   ]delay     
               >28            eom              
               >29   
               >30   dlyms    mac              
               >31            ldy   #]1        ; Delay 1ms. per iteration
               >32   ]dly     delay 1020-4     ; Cycles per ms. - 4
               >33            dey              
               >34            bne   ]dly       
               >35            eom              
               >36   
               >37   align    mac              
               >38            ds    *-1/]1*]1+]1-* 
               >39            eom              
               >40   
 
                ===== Page 9 -  NADA.PRODOS - Nov. 17, 2004 =====
  
                52           put   NADADEFS   
               >1    **********************************************************
               >2    *                                                        *
               >3    *                 NadaNet Definitions                    *
               >4    *                                                        *
               >5    *            Michael J. Mahon - Oct 13, 2004             *
               >6    *                 Revised Nov 05, 2004                   *
               >7    *                                                        *
               >8    *                  Copyright (c) 2004                    *
               >9    *                                                        *
               >10   **********************************************************
               >11   
               >12   ********************* Entry points ***********************
               >13   
9100: 20 E6 91 >15   entry    jsr   INSTALL    ; BOOT entry: init and
9103: 20 81 93 >16   servelp  jsr   SERVER     ;  Run request server
9106: 4C 03 91 >17            jmp   servelp    ;   forever...
               >18   
9109: 4C E6 91 >19   init     jmp   INSTALL    ; Initialize and return
910C: 4C 81 93 >20   serve    jmp   SERVER     ; Run request server
910F: 4C A0 94 >22   peek     jmp   PEEKREQ    
9112: 4C 4C 95 >23   poke     jmp   POKEREQ    
9115: 4C D7 95 >24   call     jmp   CALLREQ    
9118: 4C AA 96 >25   putmsg   jmp   PUTMREQ    
911B: 4C DD 96 >26   getmsg   jmp   GETMREQ    
911E: 4C A2 95 >27   bpoke    jmp   BPOKEREQ   
9121: 4C 19 95 >28   peekinc  jmp   PKINCREQ   
9124: 4C 15 97 >39   monitor  jmp   MONITOR    ; Record pkts to mem buffer
               >50   
               >51   ********** Control Packet Definition **********
               >52   
               >53            dum   0          ; Control packet format:
0000: 00       >54   req      ds    1          ;   Request
0001: 00       >55   mod      ds    1          ;   Request modifier
0002: 00       >56   dst      ds    1          ;   Destination ID (0 = bcast)
0003: 00       >57   frm      ds    1          ;   Sending ID (never 0)
0004: 00 00    >58   adr      ds    2          ;   Address field
0006: 00 00    >59   len      ds    2          ;   Length field
               >60                             ; =========================
               >61   lenctl   ds    0          ; Length of control packet
               >62            dend             
               >63   
               >64   * Request codes and modifiers
               >65   
               >66            dum   1          ; Request codes (0 invalid):
0001: 00       >67   r_PEEK   ds    1          ;   PEEK request
0002: 00       >68   r_POKE   ds    1          ;   POKE request
0003: 00       >69   r_CALL   ds    1          ;   CALL request
0004: 00       >70   r_PUTMSG ds    1          ;   PUTMSG request
0005: 00       >71   r_GETMSG ds    1          ;   GETMSG request
0006: 00       >72   r_GETID  ds    1          ;   GETID request
0007: 00       >73   r_BOOT   ds    1          ;   BOOT request
0008: 00       >74   r_BPOKE  ds    1          ;   Broadcast POKE request
0009: 00       >75   r_PKINC  ds    1          ;   PEEK & INCrement request
               >76                             ; ==========================
               >77   maxreq   ds    0          ;   Max request + 1
               >78            dend             
               >79   
               >80            dum   1          ; Modifier codes (0 invalid):
0001: 00       >81   rm_REQ   ds    1          ;   Request
0002: 00       >82   rm_ACK   ds    1          ;   Acknowledge
0003: 00       >83   rm_DACK  ds    1          ;   Data Acknowledge
0004: 00       >84   rm_NAK   ds    1          ;   Negative Acknowledge
               >85            dend             
 
                ===== Page 10 -  NADA.PRODOS - Nov. 17, 2004 =====
  
               >87   ************ NadaNet Page 3 Vector *************
               >88   
               >89            dum   $3CC       ; Fixed memory vector
03CC: 00       >90   bootself db    0          ; Machine ID from BOOT
03CD: 4C 00 00 >91   warmstrt jmp   0*0        ; Warm start SERVE loop entry
               >92   nadapage equ   *-1        ; NADANET load page
               >93            dend             
               >94   
               >95   ********** Parameters and variables ************
               >96   
               >100  
9127: 00       >101  self     db    0          ; Our own machine ID (1..15)
9128: 00 00 00 >102  sbuf     ds    lenctl     ; Control pkt send buffer
9130: 00 00 00 >103  rbuf     ds    lenctl     ; Control pkt receive buffer
9138: 00 00    >104  locaddr  dw    0          ; Local address of req data
913A: 32       >105  retrylim db    maxretry   ; Limit of REQUEST resends
913B: 00 00    >106  errprot  dw    0          ; Protocol error count
913D: 00 00    >107  ckerr    dw    0          ; Checksum error count
913F: 00       >108  servecnt db    0          ; SERVE iterations (0=256)
9140: 00 00    >110  bootadr  dw    0          ; Slave boot address
9142: 00 00    >111  bootlen  dw    0          ; Slave boot length
9144: 00 00    >112  bootcode dw    0          ; Local addr of boot code
               >113  
               >114  * Table of allocated machine IDs (allocated = non-zero)
               >115  
9146: FF 04 00 >116  idtable  db    $FF,4+dos,0,0,0,0,0,0,0,0,0,0,0,0,0,0 
               >118  
               >119  parmsiz  equ   *-self     ; Size of parameter area
               >120  
               >121  ************* Counters and Flags ***************
               >122  
9156: 5C       >123  arbxv    db    arbx       ; Arbitrate X iters (modified)
9157: 01       >124  tolim    db    reqto      ; RCVPKT timeout limit
9158: 00       >125  sendck   db    0          ; 1 = send cksum flag
9159: 00       >126  reqretry db    0          ; xxxREQ retries remaining
915A: 00       >127  retrycnt db    0          ; REQUEST resend count
915B: 08       >128  reqctr   db    8          ; SERVER request counter
915C: 32       >130  bootctr  db    bootcnt    ; BOOT frequency timer
915D: 00       >131  bootflg  db    0          ; BOOT(s) pending if not 0
915E: 00       >132  getidflg db    0          ; Recent GETID(s) processed
               >133  
                53           put   AMPERSAND  
 
                ===== Page 11 -  NADA.PRODOS - Nov. 17, 2004 =====
  
               >2    **********************************************************
               >3    *                                                        *
               >4    *                  A M P E R N A D A                     *
               >5    *                                                        *
               >6    *           Michael J. Mahon - Oct 25, 2004              *
               >7    *                Revised Nov 13, 2004                    *
               >8    *                                                        *
               >9    *                 Copyright (c) 2004                     *
               >10   *                                                        *
               >11   *  Implements an ampersand (&) interface to NadaNet for  *
               >12   *  Applesoft programs.  Reduces the need for PEEKs and   *
               >13   *  POKEs to set up parameters, saving time and interface *
               >14   *  definitions.                                          *
               >15   *                                                        *
               >16   *  If an error occurs in a command execution routine,    *
               >17   *  (signaled by Carry set upon return) the handler will, *
               >18   *  by default, throw a "DATA" (49) error, which will halt*
               >19   *  the program unless caught by an active ONERR.         *
               >20   *                                                        *
               >21   *  If an ampersand command is followed by a "#", then no *
               >22   *  execution error will be thrown, and the programmer    *
               >23   *  is responsible for checking status by PEEKing 1 and 0.*
               >24   *                                                        *
               >25   **********************************************************
               >26   
               >27   **************** Applesoft Definitions *******************
               >28   
               >29   TXTPTR   equ   $B8        ; Current scan point
               >30   VALTYP   equ   $11        ; $FF if var is STRING$
               >31   INTFLG   equ   $12        ; $80 if var is INT%
               >32   FORPNT   equ   $85        ; Ptr to var
               >33   FAC      equ   $9D        ; Floating point accum
               >34   
               >35   AMPVECT  equ   $3F5       ; JMP to ampersand handler
               >36   
               >37   CHRGET   equ   $00B1      ; Get next text char
               >38   CHRGOT   equ   $00B7      ; Get last text char
               >39   ERROR    equ   $D412      ; Applesoft error handler
               >40   SYNERR   equ   $DEC9      ; Syntax Error
               >41   ADDON    equ   $D998      ; Advance TCTPTR by Y
               >42   SYNCHR   equ   $DEC0      ; Current char must = A
               >43   FRMNUM   equ   $DD67      ; Eval expr to FAC
               >44   PTRGET   equ   $DFE3      ; Get var, ptr in (Y,A)
               >45   GETBYT   equ   $E6F8      ; Eval expr to X
               >46   GETADR   equ   $E752      ; Eval expr to (Y,A)
               >47   FLO2     equ   $EBA0      ; Normalize FAC (C set)
               >48   SETFOR   equ   $EB27      ; Pack FAC to (FORPNT)
               >49   
               >50   ********************** Variables *************************
               >51   
               >52   cmdptr   equ   $EC        ; Cmd table cursor
               >53   cmdsave  equ   $ED        ; Current parm descriptor
               >54   disp     equ   $EF        ; Displacement to parm value
               >55   
915F: 00       >56   instald  db    0          ; Installed flag
9160: 00       >57   nparms   db    0          ; # of parms seen
9161: 00       >58   errstop  db    0          ; "Throw error" flag
9162: 00       >59   varcmd   db    0          ; var parm descriptor
9163: 00       >60   vartype  db    0          ; variable type
9164: 00 00    >61   varadr   da    0          ; variable address
 
                ===== Page 12 -  NADA.PRODOS - Nov. 17, 2004 =====
  
               >63   **************** Ampersand Command Table *****************
               >64   
               >65   * Applesoft Token Definitions
               >66   
               >67   CALL_t   equ   140        
               >68   POKE_t   equ   185        
               >69   GET_t    equ   190        
               >70   PEEK_t   equ   226        
               >71   
               >72   * Syntax string definitions
               >73   
               >74   @        equ   self-1     ; Nadanet parameter origin
               >75   byte     equ   $00        ; Byte
               >76   word     equ   $40        ; Word
               >77   var      equ   $80        ; Numeric variable
               >78   
               >79            err   parmsiz/63 ; Parm area < 64 bytes
               >80   
               >81   iter     equ   servecnt-@.byte ; SERVER iteration count
               >82   dest     equ   sbuf+dst-@.byte ; Destination machine
               >83   addr     equ   sbuf+adr-@.word ; Address at destination
               >84   lngth    equ   sbuf+len-@.word ; Length
               >85   locadr   equ   locaddr-@.word  ; Local address
               >86   AX       equ   sbuf+len-@.word ; A,X regs for CALL
               >87   class    equ   sbuf+adr-@.word ; Class of message
               >88   incr     equ   sbuf+len-@.word ; Increment for PEEK INC
               >89   val      equ   sbuf+len-@.word ; Value for BPOKE
               >90   n60ms    equ   retrylim-@.byte ; Request resend limit
               >91   lngth?   equ   rbuf+len-@.word.var ; Length (var)
               >92   val?     equ   rbuf+len-@.word.var ; Value (var)
               >93   
9166: 53 45 52 >94   cmdtable asc   'SERVE',00                 ; &SERVE
916C: 19 00    >95            db    iter,0     
916E: 81 93    >96            da    SERVER     
               >97   
9170: 50 55 54 >98            asc   'PUTMSG',00                ; &PUTMSG
9177: 04 46 48 >99            db    dest,class,lngth,locadr,0 
917C: AA 96    >100           da    PUTMREQ    
               >101  
917E: BE 4D 53 >102           db    GET_t,'M','S','G',0        ; &GETMSG
9183: 04 46 D0 >103           db    dest,class,lngth?,locadr,0 
9188: DD 96    >104           da    GETMREQ    
               >105  
918A: E2 49 4E >106           db    PEEK_t,'I','N','C',0       ; &PEEKINC
918F: 04 46 48 >107           db    dest,addr,incr,val?,0 
9194: 19 95    >108           da    PKINCREQ   
               >109  
9196: E2 00    >110           db    PEEK_t,0                   ; &PEEK
9198: 04 46 48 >111           db    dest,addr,lngth,locadr,0 
919D: A0 94    >112           da    PEEKREQ    
               >113  
919F: B9 00    >114           db    POKE_t,0                   ; &POKE
91A1: 04 46 48 >115           db    dest,addr,lngth,locadr,0 
91A6: 4C 95    >116           da    POKEREQ    
               >117  
91A8: 8C 00    >118           db    CALL_t,0                   ; &CALL
91AA: 04 46 48 >119           db    dest,addr,AX,0 
91AE: D7 95    >120           da    CALLREQ    
               >121  
91B0: 42 B9 00 >122           db    'B',POKE_t,0               ; &BPOKE
91B3: 46 48 00 >123           db    addr,val,0 
91B6: A2 95    >124           da    BPOKEREQ   
               >125  
91B8: 49 4E 49 >126           asc   'INIT',00                  ; &INIT
91BD: 00       >127           db    0          
91BE: 5B 93    >128           da    INIT       
               >129  
91C0: 54 49 4D >130           asc   'TIMEOUT',00               ; &TIMEOUT
91C8: 14 00    >131           db    n60ms,0    
91CA: 30 93    >132           da    timeout    
 
                ===== Page 13 -  NADA.PRODOS - Nov. 17, 2004 =====
 
               >133  
               >135  baddr    equ   bootadr-@.word  ; Address at destination
               >136  bleng    equ   bootlen-@.word  ; Length
               >137  blocadr  equ   bootcode-@.word ; Local address
               >138  
91CC: 42 4F 4F >139           asc   'BOOTCODE',00              ; &BOOTCODE
91D5: 5A 5C 5E >140           db    baddr,bleng,blocadr,0 
91D9: 3A 93    >141           da    null       
               >142  
91DB: 49 44 54 >143           asc   'IDTBL',00                 ; &IDTBL
91E1: D0 00    >144           db    val?,0     
91E3: 3D 93    >145           da    idtbl      
               >146  
91E5: 00       >148           db    0          ; End of Command Table
 
                ===== Page 14 -  NADA.PRODOS - Nov. 17, 2004 =====
  
               >150  **********************************************************
               >151  *                                                        *
               >152  *                    I N S T A L L                       *
               >153  *                                                        *
               >154  *           Michael J. Mahon - Oct 25, 2004              *
               >155  *                Revised Nov 01, 2004                    *
               >156  *                                                        *
               >157  *                 Copyright (c) 2004                     *
               >158  *                                                        *
               >159  *  Installs AmperNada as first ampersand routine (if not *
               >160  *  installed already) and chains to an existing routine. *
               >161  *  if no routine is currently installed, it defaults to  *
               >162  *  "SYNTAX ERROR".                                       *
               >163  *                                                        *
               >164  **********************************************************
               >165  
91E6: AD 5F 91 >166  INSTALL  lda   instald    ; AmperNada installed?
91E9: D0 25    >167           bne   :exit      ; -Yes, don't repeat.
91EB: CE 5F 91 >168           dec   instald    ; -No, set flag and install.
91EE: A9 4C    >169           lda   #$4C       ; Is JMP instruction
91F0: CD F5 03 >170           cmp   AMPVECT    ;  in "&" vector?
91F3: F0 05    >171           beq   :chain     ; -Yes, chain to it.
91F5: 8D F5 03 >172           sta   AMPVECT    ; -No, set the "jmp"
91F8: D0 0C    >173           bne   :setvect   ; (always)
               >174  
               >175  :chain   mov16 AMPVECT+1;chain+1 ; Save current.
91FA: AD F6 03 >175           lda   AMPVECT+1  ; Move 2 bytes
91FD: 8D 2A 92 >175           sta   chain+1    
9200: AD F7 03 >175           lda   1+AMPVECT+1 
9203: 8D 2B 92 >175           sta   1+chain+1  
               >175           eom              
               >176  :setvect mov16 #AMPNADA;AMPVECT+1 ; set the vector.
9206: A9 13    >176           lda   #AMPNADA   ; Move 2 bytes
9208: 8D F6 03 >176           sta   AMPVECT+1  
920B: A9 92    >176           lda   #AMPNADA/$100 ; high byte of immediate
920D: 8D F7 03 >176           sta   1+AMPVECT+1 
               >176           eom              
9210: 4C 5B 93 >177  :exit    jmp   INIT       ; Initialize NadaNet.
 
                ===== Page 15 -  NADA.PRODOS - Nov. 17, 2004 =====
  
               >179  **********************************************************
               >180  *                                                        *
               >181  *                  A M P E R N A D A                     *
               >182  *                                                        *
               >183  *           Michael J. Mahon - Oct 25, 2004              *
               >184  *                Revised Nov 08, 2004                    *
               >185  *                                                        *
               >186  *                 Copyright (c) 2004                     *
               >187  *                                                        *
               >188  *  Implements an ampersand (&) interface to NadaNet for  *
               >189  *  Applesoft programs.  Reduces the need for PEEKs and   *
               >190  *  POKEs to set up parameters, saving time and interface *
               >191  *  definitions.                                          *
               >192  *                                                        *
               >193  **********************************************************
               >194  
9213: 08       >195  AMPNADA  php              ; Save status
9214: 48       >196           pha              ;  and A for chain.
9215: A2 00    >197           ldx   #0         
9217: 8E 60 91 >198           stx   nparms     ; # of parms supplied
921A: 8E 62 91 >199           stx   varcmd     ; Signal no var params seen
921D: 8E 61 91 >200           stx   errstop    ; Clear "throw err" flag.
9220: A0 00    >201  cmd      ldy   #0         ; Start compare at TXTPTR
9222: BD 66 91 >202           lda   cmdtable,x ; Get command char
9225: D0 05    >203           bne   comp       ; -Not end, compare.
9227: 68       >204           pla              ; -End.  Restore A
9228: 28       >205           plp              ;   and status and chain
9229: 4C C9 DE >206  chain    jmp   SYNERR     ;    to next & handler.
               >207  
922C: D1 B8    >208  comp     cmp   (TXTPTR),y ; Does cmd match text?
922E: D0 09    >209           bne   :skipcmd   ; -No, skip this one.
9230: C8       >210           iny              ; -Yes, advance.
9231: E8       >211           inx              
9232: BD 66 91 >212           lda   cmdtable,x ; End of command?
9235: D0 F5    >213           bne   comp       ; -No, keep comparing.
9237: F0 11    >214           beq   :doit      ; -Yes, go do it.
               >215  
9239: E8       >216  :skipcmd inx              ; Skip to end of
923A: BD 66 91 >217           lda   cmdtable,x ;  current cmd string
923D: D0 FA    >218           bne   :skipcmd   
923F: E8       >219  :skipp   inx              ; Skip to end of
9240: BD 66 91 >220           lda   cmdtable,x ;  current parm vect
9243: D0 FA    >221           bne   :skipp     
9245: E8       >222           inx              ; Pass end mark
9246: E8       >223           inx              ;  and action
9247: E8       >224           inx              ;   routine address.
9248: D0 D6    >225           bne   cmd        ; Go check next command.
               >226  
924A: 68       >227  :doit    pla              ; Discard entry A
924B: 68       >228           pla              ;  and status.
924C: B1 B8    >229           lda   (TXTPTR),y ; Look at next character.
924E: C8       >230           iny              ; (provisional match)
924F: C9 23    >231           cmp   #'#'       ; Is it "#"?
9251: F0 04    >232           beq   :advance   ; -Yes, don't throw error.
9253: 88       >233           dey              ; -No, don't match, and
9254: EE 61 91 >234           inc   errstop    ;   set throw err flag.
9257: 20 98 D9 >235  :advance jsr   ADDON      ; Advance TXTPTR past cmd
925A: A9 28    >236           lda   #'('       ; Require initial "("
925C: 20 C0 DE >237  :nxparm  jsr   SYNCHR     ; Syntax err if no match.
925F: F0 61    >238           beq   :synerr    ; End not expected.
9261: 86 EC    >239           stx   cmdptr     ; Save for :done case
9263: C9 29    >240           cmp   #')'       ; Found a ")"?
9265: F0 5E    >241           beq   :done      ; -Yes, end of parm list.
9267: EE 60 91 >242           inc   nparms     ; -No, another parm.
926A: E8       >243           inx              ; Advance ptr and
926B: BD 66 91 >244           lda   cmdtable,x ;  get parm descriptor.
926E: F0 52    >245           beq   :synerr    ; Too many parms.
9270: 85 ED    >246           sta   cmdsave    ; Save descriptor
9272: 29 3F    >247           and   #$3F       ; Mask displacement
9274: 85 EF    >248           sta   disp       ;  and save it.
 
                ===== Page 16 -  NADA.PRODOS - Nov. 17, 2004 =====
 
9276: 86 EC    >249           stx   cmdptr     ; Save pointer.
9278: 24 ED    >250           bit   cmdsave    ; Test parm type.
927A: 30 20    >251           bmi   :var       ; -Var parm
927C: 50 12    >252           bvc   :byte      ; -Byte value parm
927E: 20 67 DD >253           jsr   FRMNUM     ; -Word value parm
9281: 20 52 E7 >254           jsr   GETADR     ; Word val to Y,A
9284: A6 EF    >255           ldx   disp       
9286: 9D 27 91 >256           sta   @+1,x      ; Store the value
9289: 98       >257           tya              
928A: 9D 26 91 >258           sta   @,x        
928D: 4C B3 92 >259           jmp   :more?     
               >260  
9290: 20 F8 E6 >261  :byte    jsr   GETBYT     ; Byte value to X
9293: A4 EF    >262           ldy   disp       
9295: 8A       >263           txa              
9296: 99 26 91 >264           sta   @,y        ; Store the value
9299: 4C B3 92 >265           jmp   :more?     
               >266  
929C: A5 ED    >267  :var     lda   cmdsave    ; Save the parm
929E: 8D 62 91 >268           sta   varcmd     ;  descriptor.
92A1: 20 E3 DF >269           jsr   PTRGET     ; Get var ptr in (A,Y)
92A4: 8D 64 91 >270           sta   varadr     ;  and save var
92A7: 8C 65 91 >271           sty   varadr+1   ;   address.
92AA: A5 11    >272           lda   VALTYP     ; $FF if string
92AC: D0 14    >273           bne   :synerr    ; String not allowed.
92AE: A5 12    >274           lda   INTFLG     ; $80 if INT%
92B0: 8D 63 91 >275           sta   vartype    ; Save for later use
92B3: 20 B7 00 >276  :more?   jsr   CHRGOT     ; Check current test char.
92B6: F0 0A    >277           beq   :synerr    ; End not expected.
92B8: C9 29    >278           cmp   #')'       ; Closing ")"?
92BA: F0 09    >279           beq   :done      ; -Yes, finish.
92BC: A6 EC    >280           ldx   cmdptr     ; -No, more parms.
92BE: A9 2C    >281           lda   #','       ; Require a comma.
92C0: D0 9A    >282           bne   :nxparm    ; (always)
               >283  
92C2: 4C C9 DE >284  :synerr  jmp   SYNERR     ; SYNTAX ERROR
               >285  
92C5: 20 B1 00 >286  :done    jsr   CHRGET     ; Pass the ")"
92C8: A6 EC    >287           ldx   cmdptr     
92CA: E8       >288  :skipit  inx              ; Skip to end
92CB: BD 66 91 >289           lda   cmdtable,x ;  of parm descriptors.
92CE: D0 FA    >290           bne   :skipit    
               >291           mov16 cmdtable+1,x;:jsr+1 ; Action routine
92D0: BD 67 91 >291           lda   cmdtable+1,x ; Move 2 bytes
92D3: 8D DD 92 >291           sta   :jsr+1     
92D6: BD 68 91 >291           lda   1+cmdtable+1,x 
92D9: 8D DE 92 >291           sta   1+:jsr+1   
               >291           eom              
92DC: 20 00 00 >292  :jsr     jsr   0*0        ; Call the action routine
92DF: 85 00    >293           sta   $00        ; Save returned A
92E1: A9 00    >294           lda   #0         
92E3: 2A       >295           rol              ; C to low bit
92E4: 85 01    >296           sta   $01        ; Save returned Carry
92E6: F0 0A    >297           beq   :noerr     ; No error, continue.
92E8: AD 61 91 >298           lda   errstop    ; Throw error?
92EB: F0 0A    >299           beq   :rts       ; -No, just return.
92ED: A2 31    >300           ldx   #49        ; -Yes, throw "DATA"
92EF: 4C 12 D4 >301           jmp   ERROR      ;   error.
               >302  
92F2: AD 62 91 >303  :noerr   lda   varcmd     ; Var parm passed?
92F5: D0 01    >304           bne   :store     ; -Yes, store into it.
92F7: 60       >305  :rts     rts              ; -No, return.
               >306  
92F8: 29 3F    >307  :store   and   #$3F       ; Mask displacement
92FA: A8       >308           tay              
92FB: B9 26 91 >309           lda   @,y        ; Get low byte
92FE: AA       >310           tax              ; X = lo byte of value
92FF: A9 00    >311           lda   #0         ; Hi byte if byte value
9301: 2C 62 91 >312           bit   varcmd     ; Is it byte or word?
9304: 50 03    >313           bvc   :byteval   ; -Byte, use 0 hi byte
 
                ===== Page 17 -  NADA.PRODOS - Nov. 17, 2004 =====
 
9306: B9 27 91 >314           lda   @+1,y      ; -Word, get hi byte
9309: A8       >315  :byteval tay              ; Y = hi byte of value
               >316           mov16 varadr;FORPNT ; Address of variable
930A: AD 64 91 >316           lda   varadr     ; Move 2 bytes
930D: 85 85    >316           sta   FORPNT     
930F: AD 65 91 >316           lda   1+varadr   
9312: 85 86    >316           sta   1+FORPNT   
               >316           eom              
9314: AD 63 91 >317           lda   vartype    ; INT% or FLOAT variable?
9317: 10 0A    >318           bpl   :float     ; -FLOAT
9319: 98       >319           tya              ; -INT%
931A: A0 00    >320           ldy   #0         ; Store hi byte
931C: 91 85    >321           sta   (FORPNT),y ;  in INT% variable.
931E: C8       >322           iny              ; Point to lo byte
931F: 8A       >323           txa              ; Store lo byte
9320: 91 85    >324           sta   (FORPNT),y ;  in INT% variable.
9322: 60       >325           rts              
               >326  
9323: 84 9E    >327  :float   sty   FAC+1      ; Hi byte to FAC
9325: 86 9F    >328           stx   FAC+2      ; Lo byte to FAC
9327: A2 90    >329           ldx   #$90       ; Binary point 16 bits right
9329: 38       >330           sec              ; (Don't negate FAC)
932A: 20 A0 EB >331           jsr   FLO2       ; Normalize FAC
932D: 4C 27 EB >332           jmp   SETFOR     ; Pack FAC into variable.
 
                ===== Page 18 -  NADA.PRODOS - Nov. 17, 2004 =====
  
               >334  **********************************************************
               >335  *                                                        *
               >336  *                 &TIMEOUT ([n60ms])                     *
               >337  *                                                        *
               >338  *           Michael J. Mahon - Oct 28, 2004              *
               >339  *                                                        *
               >340  *                 Copyright (c) 2004                     *
               >341  *                                                        *
               >342  *  Set new request timeout value in units of 60 ms.      *
               >343  *                                                        *
               >344  *  If no value is supplied, reset timeout to default.    *
               >345  *                                                        *
               >346  **********************************************************
               >347  
9330: AD 60 91 >348  timeout  lda   nparms     ; Parm supplied?
9333: D0 05    >349           bne   null       ; -Yes, timeout set.
9335: A9 32    >350           lda   #maxretry  ; -No, restore
9337: 8D 3A 91 >351           sta   retrylim   ;   the default.
933A: 68       >352  null     pla              ; No post-action
933B: 68       >353           pla              ;  processing needed.
933C: 60       >354           rts              
 
                ===== Page 19 -  NADA.PRODOS - Nov. 17, 2004 =====
  
               >357  **********************************************************
               >358  *                                                        *
               >359  *                    &IDTBL (val?)                       *
               >360  *                                                        *
               >361  *           Michael J. Mahon - Nov 05, 2004              *
               >362  *                                                        *
               >363  *                 Copyright (c) 2004                     *
               >364  *                                                        *
               >365  *  Return address of 'idtable' in parm variable.         *
               >366  *                                                        *
               >367  **********************************************************
               >368  
               >369  idtbl    mov16 #idtable;rbuf+len ; Put addr in rbuf
933D: A9 46    >369           lda   #idtable   ; Move 2 bytes
933F: 8D 36 91 >369           sta   rbuf+len   
9342: A9 91    >369           lda   #idtable/$100 ; high byte of immediate
9344: 8D 37 91 >369           sta   1+rbuf+len 
               >369           eom              
9347: 18       >370           clc              
9348: 60       >371           rts              
 
                ===== Page 20 -  NADA.PRODOS - Nov. 17, 2004 =====
  
                54           put   INITSERVE  
               >2    *** Table of service routines used by SERVER ***
               >3    
9349: E2 94    >4    service  dw    PEEKSRV    ; Table of service routines
934B: 7B 95    >5             dw    POKESRV    ; (Must be in order)
934D: EA 95    >6             dw    CALLSRV    
934F: 17 94    >11            dw    ]PROTERR   ; (Error if PUTMSG)
9351: 17 94    >12            dw    ]PROTERR   ; (Error if GETMSG)
9353: 6E 94    >15            dw    GETIDSRV   ; Master serves GETID
9355: 17 94    >19            dw    ]PROTERR   ; (Error if BOOT)
9357: C1 95    >20            dw    BPOKESRV   
9359: 2C 95    >21            dw    PKINCSRV   
 
                ===== Page 21 -  NADA.PRODOS - Nov. 17, 2004 =====
  
               >23   **********************************************************
               >24   *                                                        *
               >25   *                        I N I T                         *
               >26   *                                                        *
               >27   *             Michael J. Mahon - Mar 5, 2004             *
               >28   *                  Revised Oct 18, 2004                  *
               >29   *                                                        *
               >30   *                Copyright (c) 1996, 2004                *
               >31   *                                                        *
               >32   *  Initialize NADANET and return to caller.              *
               >33   *                                                        *
               >34   **********************************************************
               >35   
935B: AD CC 03 >36   INIT     lda   bootself   ; Set up ID from BOOT
935E: 20 71 93 >37            jsr   setid      
9361: A9 4C    >38            lda   #$4C       ; Set up warmstrt JMP
9363: 8D CD 03 >39            sta   warmstrt   ;  to servlp.
9366: A9 03    >40            lda   #<servelp  
9368: 8D CE 03 >41            sta   warmstrt+1 
936B: A9 91    >42            lda   #>entry    ; Put NADANET load page
936D: 8D CF 03 >43            sta   nadapage   ;  in fixed low address.
9370: 60       >44            rts              
 
                ===== Page 22 -  NADA.PRODOS - Nov. 17, 2004 =====
  
               >47   **********************************************************
               >48   *                                                        *
               >49   *                       S E T I D                        *
               >50   *                                                        *
               >51   *            Michael J. Mahon - May 13, 2004             *
               >52   *                  Revised Nov 05, 2004                  *
               >53   *                                                        *
               >54   *                   Copyright (c) 2004                   *
               >55   *                                                        *
               >56   *  Set machine ID to contents of A register and reset    *
               >57   *  the arbitration delay to 'arbtime' plus 22 cycles     *
               >58   *  times the machine ID, to avoid collisions.            *
               >59   *                                                        *
               >60   *  Delay from last arbitration poll to bus lock is 10    *
               >61   *  cycles, so 22 (2 * 11 cycles) increment provides a    *
               >62   *  little insurance.                                     *
               >63   *                                                        *
               >64   **********************************************************
               >65   
9371: 8D 27 91 >66   setid    sta   self       ; Machine ID (1..15)
9374: 8D 2B 91 >67            sta   sbuf+frm   ; Set sender field.
9377: AA       >68            tax              ; Temp ID? (hi bit set)
9378: 30 03    >69            bmi   :setarb    ; -Yes, use directly.
937A: 0A       >70            asl              ; -No, mult ID by 2
937B: 69 5C    >71            adc   #arbx      ; Add to base
937D: 8D 56 91 >72   :setarb  sta   arbxv      ;  delay.
9380: 60       >73            rts              
 
                ===== Page 23 -  NADA.PRODOS - Nov. 17, 2004 =====
  
               >76   **********************************************************
               >77   *                                                        *
               >78   *                      S E R V E R                       *
               >79   *                                                        *
               >80   *             Michael J. Mahon - May 5, 1996             *
               >81   *                  Revised Nov 10, 2004                  *
               >82   *                                                        *
               >83   *                Copyright (c) 1996, 2004                *
               >84   *                                                        *
               >85   *  SERVER continually listens to the net, receiving all  *
               >86   *  packets, and responding to control packets directed   *
               >87   *  to 'self'.  If a key is pressed or a request handled, *
               >88   *  SERVER returns. C = 0 if count expired and is set as  *
               >89   *  the request server left it if a request was handled.  *
               >90   *                                                        *
               >91   *  To minimize missed polls, SERVER temporarily raises   *
               >92   *  RCVPKT's timeout to 20ms. from the normal value equal *
               >93   *  to the minimum arbitration time.                      *
               >94   *                                                        *
               >95   *  For every request code, there is a corresponding      *
               >96   *  server routine.  SERVER invokes these routines to     *
               >97   *  satisfy the service requests it receives.             *
               >99   *                                                        *
               >100  *  If master, every 'bootcnt' iterations, SERVER checks  *
               >101  *  to see if any GETIDs were processed in the previous   *
               >102  *  interval, and, if not, checks whether any BOOTs are   *
               >103  *  pending, and, if so, sends a BOOT request.            *
               >104  *                                                        *
               >105  *  This delay has the effect of accumulating multiple    *
               >106  *  BOOTs to be satisfied with one broadcast BOOT request.*
               >108  *                                                        *
               >109  *  Since 8-byte data packets are indistinguishable from  *
               >110  *  control packets, it is necessary to wait for the net  *
               >111  *  to be idle or locked for at least the min arb time    *
               >112  *  before receiving a request, to ensure that the next   *
               >113  *  packet received is the start packet of a request      *
               >114  *  protocol.  BPOKE is the only request that begins with *
               >115  *  a locked state.                                       *
               >116  *                                                        *
               >117  **********************************************************
               >118  
9381: A2 3A    >119  SERVER   ldx   #servegap  ; Delay min arb time
9383: CD E8 C0 >120           cmp   zipslow    ; Zip Chip to 1MHz mode.
9386: AC 62 C0 >121           ldy   drecv      ; Sample net state.
9389: 98       >122  :waitidl tya              
938A: 4D 62 C0 >123           eor   drecv      ; Has net changed?
938D: 30 F2    >124           bmi   SERVER     ; -Yes, restart timing.
938F: CA       >125           dex              ; -No, count it down.
9390: D0 F7    >126           bne   :waitidl   
9392: AD 00 C0 >127  :serve   lda   keybd      ; Check if key pressed.
9395: 30 77    >128           bmi   :rts       ; -Yes, return.
9397: A0 08    >129           ldy   #idleto    ; While polling, raise
9399: 8C 57 91 >130           sty   tolim      ;  RCVPKT timeout to 20ms.
939C: 20 FB 98 >131           jsr   RCVCTL     ; Receive ctl pkt to 'rbuf'
939F: 08       >132           php              ; Save flags,
93A0: A0 01    >133           ldy   #reqto     ;  reset timeout to min
93A2: 8C 57 91 >134           sty   tolim      ;   arbitration time,
93A5: 28       >135           plp              ;    and restore flags.
93A6: 90 0D    >136           bcc   :ok        
93A8: F0 3E    >137           beq   :timeout   ; Timed out.
               >138           inc16 ckerr      ; Tally cksum error
93AA: EE 3D 91 >138           inc   ckerr      ; Increment 16-bit word.
93AD: D0 03    >138           bne   *+5        ; - No carry.
93AF: EE 3E 91 >138           inc   ckerr+1    ; Propagate carry.
               >138           eom              
93B2: 4C DE 93 >139           jmp   :done      ;  and keep time.
               >140  
93B5: AD 32 91 >141  :ok      lda   rbuf+dst   ; Good packet.
93B8: F0 56    >142           beq   :bcastck   ; Broadcast packet OK?
93BA: CD 27 91 >143           cmp   self       ; Directed to us?
 
                ===== Page 24 -  NADA.PRODOS - Nov. 17, 2004 =====
 
93BD: D0 1F    >144           bne   :done      ; -No, just keep time.
93BF: AD 31 91 >145  :bcast   lda   rbuf+mod   ; -Yes, check modifier.
93C2: C9 01    >146           cmp   #rm_REQ    ; Is it a Request?
93C4: D0 51    >147           bne   ]PROTERR   ; -No, protocol error.
93C6: AD 30 91 >148           lda   rbuf+req   ; -Yes, check request.
93C9: F0 4C    >149           beq   ]PROTERR   ; Code must be > 0
93CB: C9 0A    >150           cmp   #maxreq    ;  and < maxreq.
93CD: B0 48    >151           bcs   ]PROTERR   ; Invalid request.
93CF: 0A       >152           asl              ; Code * 2
93D0: A8       >153           tay              ; Index of service routine
               >154           mov16 service-2,y;address ; Set up address
93D1: B9 47 93 >154           lda   service-2,y ; Move 2 bytes
93D4: 85 FC    >154           sta   address    
93D6: B9 48 93 >154           lda   1+service-2,y 
93D9: 85 FD    >154           sta   1+address  
               >154           eom              
93DB: 6C FC 00 >155           jmp   (address)  ; Jump to service routine.
               >156  
93DE: CE 5B 91 >157  :done    dec   reqctr     ; 8 requests seen?
93E1: D0 9E    >158           bne   SERVER     ; -No, keep serving.
93E3: A9 08    >159           lda   #8         ; -Yes, about 20ms used.
93E5: 8D 5B 91 >160           sta   reqctr     ; Reset counter.
               >161  :timeout                  
93E8: CE 5C 91 >163           dec   bootctr    ; Has 'bootwait' elapsed?
93EB: D0 1C    >164           bne   :ret       ; -No, return.
93ED: A9 32    >165           lda   #bootcnt   ; -Yes, reset counter
93EF: 8D 5C 91 >166           sta   bootctr    
93F2: AD 5E 91 >167           lda   getidflg   ; Any GETIDs processed?
93F5: F0 0A    >168           beq   :ckboot    ; -No, check pending BOOTs.
93F7: 8D 5D 91 >169           sta   bootflg    ; -Yes, set BOOT pending,
93FA: A9 00    >170           lda   #0         ;   clear the
93FC: 8D 5E 91 >171           sta   getidflg   ;    GETID flag,
93FF: F0 08    >172           beq   :ret       ; (always)
               >173  
9401: AD 5D 91 >174  :ckboot  lda   bootflg    ; Any BOOTs pending?
9404: F0 03    >175           beq   :ret       ; -No, return.
9406: 20 22 94 >176           jsr   BOOTREQ    ; -Yes, send BOOT request.
               >177  :ret                      
9409: CE 3F 91 >179           dec   servecnt   ; Enough iterations?
940C: D0 84    >180           bne   :serve     ; -No, keep serving.
940E: 18       >181  :rts     clc              ; -Yes, clear Carry
940F: 60       >182           rts              ;  return.
               >183  
9410: AD 30 91 >184  :bcastck lda   rbuf+req   ; Ck broadcast valid..
9413: C9 08    >185           cmp   #r_BPOKE   ; Broadcast POKE request?
9415: F0 A8    >186           beq   :bcast     ; -Yes, process request.
               >187  ]PROTERR inc16 errprot    ; Record protocol error
9417: EE 3B 91 >187           inc   errprot    ; Increment 16-bit word.
941A: D0 03    >187           bne   *+5        ; - No carry.
941C: EE 3C 91 >187           inc   errprot+1  ; Propagate carry.
               >187           eom              
941F: 4C E8 93 >188           jmp   :timeout   ;  and treat like timeout.
               >191  
               >192  *--------------------------------------------------------*
               >193  *         Requester                  Master (ID=1)       *
               >194  *  ========================     =======================  *
               >195  *  GETID  REQ              ====>                         *
               >196  *                          <==== GETID  ACK (ID)         *
               >197  *  GETID  DACK             ====>                         *
               >198  *--------(approx. 'bootdly' milliseconds later)----------*
               >199  *                          <==== BOOT  REQ (addr,leng)   *
               >200  *                          <==== Data                    *
               >201  *                            :                           *
               >202  *                          <==== Data                    *
               >203  *--------------------------------------------------------*
 
                ===== Page 25 -  NADA.PRODOS - Nov. 17, 2004 =====
  
               >205  **********************************************************
               >206  *                                                        *
               >207  *                     B O O T R E Q                      *
               >208  *                                                        *
               >209  *            Michael J. Mahon - May 14, 2004             *
               >210  *                  Revised Oct 13, 2004                  *
               >211  *                                                        *
               >212  *                   Copyright (c) 2004                   *
               >213  *                                                        *
               >214  *  Broadcast request for all machines waiting for boot   *
               >215  *  code to receive code starting at their 'bootadr', of  *
               >216  *  length 'bootlen', then give control to 'bootadr'.     *
               >217  *  Code is sent from this machine's 'bootcode'.          *
               >218  *                                                        *
               >219  *  BOOTREQ, since it is broadcast, does not receive an   *
               >220  *  ACK from its destination(s), but proceeds to send the *
               >221  *  boot code blindly.  If errors occur, the machine(s)   *
               >222  *  requiring boot will re-request with a GETID.          *
               >223  *                                                        *
               >224  *  BOOTREQ does the following steps:                     *
               >225  *     1. Sets up the address and length of the boot code *
               >226  *     2. Sends the BOOT request, with address and length *
               >227  *     3. Sends the boot code stream                      *
               >228  *                                                        *
               >229  **********************************************************
               >230  
               >231  BOOTREQ  mov16 bootadr;sbuf+adr ; Remote start address
9422: AD 40 91 >231           lda   bootadr    ; Move 2 bytes
9425: 8D 2C 91 >231           sta   sbuf+adr   
9428: AD 41 91 >231           lda   1+bootadr  
942B: 8D 2D 91 >231           sta   1+sbuf+adr 
               >231           eom              
               >232           mov16 bootlen;sbuf+len ;  and length...
942E: AD 42 91 >232           lda   bootlen    ; Move 2 bytes
9431: 8D 2E 91 >232           sta   sbuf+len   
9434: AD 43 91 >232           lda   1+bootlen  
9437: 8D 2F 91 >232           sta   1+sbuf+len 
               >232           eom              
943A: A9 00    >233           lda   #0         
943C: 8D 5D 91 >234           sta   bootflg    ; Clear the BOOT flag.
943F: 8D 2A 91 >235           sta   sbuf+dst   ; Broadcast boot code.
9442: A9 07    >236           lda   #r_BOOT    
9444: 8D 28 91 >237           sta   sbuf+req   
9447: A9 01    >238           lda   #rm_REQ    
9449: 8D 29 91 >239           sta   sbuf+mod   
944C: 20 6A 97 >240           jsr   ARBTRATE   ; Arbitrate for & lock bus
944F: 20 11 98 >241           jsr   SENDCTL    ; Send the BOOT request.
               >242           mov16 bootcode;address ; Local start address
9452: AD 44 91 >242           lda   bootcode   ; Move 2 bytes
9455: 85 FC    >242           sta   address    
9457: AD 45 91 >242           lda   1+bootcode 
945A: 85 FD    >242           sta   1+address  
               >242           eom              
               >243           mov16 bootlen;length ; Length
945C: AD 42 91 >243           lda   bootlen    ; Move 2 bytes
945F: 85 FE    >243           sta   length     
9461: AD 43 91 >243           lda   1+bootlen  
9464: 85 FF    >243           sta   1+length   
               >243           eom              
               >244           delay 150        ; Give receiver(s) time.
9466: A2 1E    >244           ldx   #150/5     ; (5 cycles per iteration)
9468: CA       >244  ]delay   dex              
9469: D0 FD    >244           bne   ]delay     
               >244           eom              
946B: 4C A0 99 >245           jmp   SENDLONG   ; Send code and return.
 
                ===== Page 26 -  NADA.PRODOS - Nov. 17, 2004 =====
  
               >247  **********************************************************
               >248  *                                                        *
               >249  *                    G E T I D S R V                     *
               >250  *                                                        *
               >251  *            Michael J. Mahon - May 14, 2004             *
               >252  *                 Revised Oct 27, 2004                   *
               >253  *                                                        *
               >254  *                   Copyright (c) 2004                   *
               >255  *                                                        *
               >256  *  Service machine 'rbuf+frm's request to allocate a new *
               >257  *  machine ID (if 'rbuf+frm' is a pseudo-ID) and flag    *
               >258  *  that boot code needs to be sent.                      *
               >259  *                                                        *
               >260  *  The new ID is sent in the ACK packet.  GETIDSRV       *
               >261  *  requires a DACK packet from the newly allocated       *
               >262  *  machine ID before the new allocation is committed.    *
               >263  *                                                        *
               >264  *  GETIDSRV is unique in that it returns control         *
               >265  *  directly to SERVER (rather than SERVER's caller), so  *
               >266  *  that all GETID requests are processed and booting is  *
               >267  *  complete before SERVER returns.                       *
               >268  *                                                        *
               >269  *  GETIDSRV does the following steps:                    *
               >270  *     1. If a pseudo-ID was received, it finds the next  *
               >271  *        available machine ID.                           *
               >272  *     2. Sends the new ID in the ACK packet              *
               >273  *     3. Receives the DACK and marks the ID allocated.   *
               >274  *     4. Gives control back to SERVER.                   *
               >275  *                                                        *
               >276  **********************************************************
               >277  
946E: AD 33 91 >278  GETIDSRV lda   rbuf+frm   ; Look at requester's ID
9471: 10 11    >279           bpl   :ack       ; -it's real, just ACK.
9473: A2 02    >280           ldx   #2         ; -pseudo, find new one.
9475: BD 46 91 >281  :search  lda   idtable,x  ; Find lowest
9478: F0 07    >282           beq   :found     ;  unused ID.
947A: E8       >283           inx              
947B: E0 10    >284           cpx   #16        
947D: 90 F6    >285           bcc   :search    
947F: B0 1C    >286           bcs   :exit      ; Table overflow!
               >287  
9481: 8E 2C 91 >288  :found   stx   sbuf+adr   ; Send new ID to requester
9484: 20 00 98 >289  :ack     jsr   SENDACK    
9487: AD 2C 91 >290           lda   sbuf+adr   ; Expect new ID
948A: 8D 2A 91 >291           sta   sbuf+dst   ;  in DACK.
948D: 20 6E 96 >292           jsr   RCVDACK    
9490: B0 0B    >293           bcs   :exit      ; -Error, don't allocate.
9492: AE 2A 91 >294           ldx   sbuf+dst   ; -OK.
9495: A9 01    >295           lda   #1         
9497: 9D 46 91 >296           sta   idtable,x  ; Allocate the ID
949A: 8E 5E 91 >297           stx   getidflg   ;  and flag the GETID.
949D: 4C 81 93 >298  :exit    jmp   SERVER     ; Go back to SERVER.
 
                ===== Page 27 -  NADA.PRODOS - Nov. 17, 2004 =====
  
                55           put   PEEKPOKECALL 
               >2    *--------------------------------------------------------*
               >3    *         Requester                     Server           *
               >4    *  ========================     =======================  *
               >5    *  PEEK   REQ (addr,leng)  ====>                         *
               >6    *                          <==== PEEK   ACK              *
               >7    *                          <==== Data (if >4 bytes)      *
               >8    *                            :                           *
               >9    *                          <==== Data                    *
               >10   *--------------------------------------------------------*
 
                ===== Page 28 -  NADA.PRODOS - Nov. 17, 2004 =====
  
               >14   **********************************************************
               >15   *                                                        *
               >16   *                     P E E K R E Q                      *
               >17   *                                                        *
               >18   *             Michael J. Mahon - May 5, 1996             *
               >19   *                                                        *
               >20   *                   Copyright (c) 1996                   *
               >21   *                                                        *
               >22   *  Request machine 'sbuf+dst' to send 'sbuf+len' bytes   *
               >23   *  at its 'sbuf+adr', and put them at location 'locaddr'.*
               >24   *                                                        *
               >25   *  PEEKREQ, like other requests, will retry the request  *
               >26   *  in case of error, up to 'maxreqrt' times.  If errors  *
               >27   *  persist, it will return with Carry set.               *
               >28   *                                                        *
               >29   *  PEEKREQ does the following steps:                     *
               >30   *     1. Make the PEEK request (and receive the ACK)     *
               >31   *     2. Receive 'sbuf+len' bytes of data into 'locaddr' *
               >32   *     3. Retry in case of error up to 'maxreqrt' times   *
               >33   *                                                        *
               >34   **********************************************************
               >35   
94A0: A9 03    >36   PEEKREQ  lda   #maxreqrt  ; Set request retry
94A2: 8D 59 91 >37            sta   reqretry   ;  counter.
94A5: A9 01    >38   :retry   lda   #r_PEEK    ; Send PEEK request.
94A7: 20 00 96 >39            jsr   REQUEST    
94AA: B0 2F    >40            bcs   :failed    
               >41            mov16 sbuf+len;length ; Set up 'length'
94AC: AD 2E 91 >41            lda   sbuf+len   ; Move 2 bytes
94AF: 85 FE    >41            sta   length     
94B1: AD 2F 91 >41            lda   1+sbuf+len 
94B4: 85 FF    >41            sta   1+length   
               >41            eom              
               >42            mov16 locaddr;address ; and 'address'
94B6: AD 38 91 >42            lda   locaddr    ; Move 2 bytes
94B9: 85 FC    >42            sta   address    
94BB: AD 39 91 >42            lda   1+locaddr  
94BE: 85 FD    >42            sta   1+address  
               >42            eom              
94C0: A5 FF    >43            lda   length+1   ; If length
94C2: D0 12    >44            bne   :long      ;  is >255 bytes, or
94C4: A4 FE    >45            ldy   length     ;    if length is
94C6: F0 19    >46            beq   :done      ; (length = 0!)
94C8: C0 05    >47            cpy   #5         ;      > 4 bytes,
94CA: B0 0A    >48            bcs   :long      ;   receive multiple pkts.
94CC: 88       >49            dey              ; Move short response
94CD: B9 34 91 >50   :short   lda   rbuf+adr,y ;  to local data address.
94D0: 91 FC    >51            sta   (address),y 
94D2: 88       >52            dey              
94D3: 10 F8    >53            bpl   :short     
94D5: 60       >54            rts              ; ...and return.
               >55   
94D6: 20 BF 99 >56   :long    jsr   RCVLONG    ; Receive multiple packets
94D9: 90 06    >57            bcc   :done      ; No problem.
94DB: CE 59 91 >58   :failed  dec   reqretry   ; Dec request retry count
94DE: D0 C5    >59            bne   :retry     ; Try until OK or exhausted,
94E0: 38       >60            sec              ;  then return with C set.
94E1: 60       >61   :done    rts              
 
                ===== Page 29 -  NADA.PRODOS - Nov. 17, 2004 =====
  
               >65   **********************************************************
               >66   *                                                        *
               >67   *                     P E E K S R V                      *
               >68   *                                                        *
               >69   *             Michael J. Mahon - May 5, 1996             *
               >70   *                                                        *
               >71   *                   Copyright (c) 1996                   *
               >72   *                                                        *
               >73   *  Service machine 'rbuf+frm's request to send 'rbuf+len'*
               >74   *  bytes of data from our 'rbuf+adr'.                    *
               >75   *                                                        *
               >76   *  PEEKSRV does the following steps:                     *
               >77   *     1. Check 'rbuf+len' for a 1..4 byte request        *
               >78   *     2. Send the ACK packet (with data, if short)       *
               >79   *     3. If long, send multiple response packets         *
               >80   *                                                        *
               >81   **********************************************************
               >82   
               >83   PEEKSRV  mov16 rbuf+adr;address ; Set up data address
94E2: AD 34 91 >83            lda   rbuf+adr   ; Move 2 bytes
94E5: 85 FC    >83            sta   address    
94E7: AD 35 91 >83            lda   1+rbuf+adr 
94EA: 85 FD    >83            sta   1+address  
               >83            eom              
               >84            mov16 rbuf+len;length ;    and length...
94EC: AD 36 91 >84            lda   rbuf+len   ; Move 2 bytes
94EF: 85 FE    >84            sta   length     
94F1: AD 37 91 >84            lda   1+rbuf+len 
94F4: 85 FF    >84            sta   1+length   
               >84            eom              
94F6: A5 FF    >85            lda   length+1   ; Check for long response
94F8: D0 14    >86            bne   :long      
94FA: A4 FE    >87            ldy   length     ; Check for < 5 bytes.
94FC: F0 0D    >88            beq   :nullreq   ; length = 0.
94FE: C0 05    >89            cpy   #5         
9500: B0 0C    >90            bcs   :long      ; - No, longer.
9502: 88       >91            dey              ; - Yes, move response
9503: B1 FC    >92   :short   lda   (address),y ;   data into ACK packet.
9505: 99 2C 91 >93            sta   sbuf+adr,y 
9508: 88       >94            dey              
9509: 10 F8    >95            bpl   :short     
950B: 4C 00 98 >96   :nullreq jmp   SENDACK    ; Send ACK with response.
               >97   
950E: 20 00 98 >98   :long    jsr   SENDACK    ; ACK the request.
               >99            delay 100        ; Allow requester to receive.
9511: A2 14    >99            ldx   #100/5     ; (5 cycles per iteration)
9513: CA       >99   ]delay   dex              
9514: D0 FD    >99            bne   ]delay     
               >99            eom              
9516: 4C A0 99 >100           jmp   SENDLONG   ; Send long response.
 
                ===== Page 30 -  NADA.PRODOS - Nov. 17, 2004 =====
  
               >102  *--------------------------------------------------------*
               >103  *         Requester                     Server           *
               >104  *  ========================     =======================  *
               >105  *  PEEKINC REQ (addr,inc)  ====>                         *
               >106  *                          <==== PEEKINC ACK (oldval)    *
               >107  *--------------------------------------------------------*
 
                ===== Page 31 -  NADA.PRODOS - Nov. 17, 2004 =====
  
               >111  **********************************************************
               >112  *                                                        *
               >113  *                    P K I N C R E Q                     *
               >114  *                                                        *
               >115  *             Michael J. Mahon - Nov 05, 2004            *
               >116  *                                                        *
               >117  *                   Copyright (c) 2004                   *
               >118  *                                                        *
               >119  *  Request machine 'sbuf+dst' to return 2 bytes at its   *
               >120  *  'sbuf+adr', then increment that value by 'sbuf+len'.  *
               >121  *  Put the returned, unincremented value at 'locaddr'.   *
               >122  *                                                        *
               >123  *  PEEKREQ, like other requests, will retry the request  *
               >124  *  in case of error, up to 'maxreqrt' times.  If errors  *
               >125  *  persist, it will return with Carry set.               *
               >126  *                                                        *
               >127  *  PEEKREQ does the following steps:                     *
               >128  *     1. Make the PEEKINC request (and receive the ACK)  *
               >129  *     2. Move 2 bytes in 'sbuf+len' into 'locaddr'       *
               >130  *     3. Retry in case of error up to 'maxreqrt' times   *
               >131  *                                                        *
               >132  **********************************************************
               >133  
9519: A9 03    >134  PKINCREQ lda   #maxreqrt  ; Set request retry
951B: 8D 59 91 >135           sta   reqretry   ;  counter.
951E: A9 09    >136  :retry   lda   #r_PKINC   ; Send PEEKINC request.
9520: 20 00 96 >137           jsr   REQUEST    
9523: 90 06    >138           bcc   :done      ; Done if no error.
9525: CE 59 91 >139           dec   reqretry   ; Dec request retry count
9528: D0 F4    >140           bne   :retry     ; Try until OK or exhausted,
952A: 38       >141           sec              ;  then return with C set.
952B: 60       >142  :done    rts              
 
                ===== Page 32 -  NADA.PRODOS - Nov. 17, 2004 =====
  
               >146  **********************************************************
               >147  *                                                        *
               >148  *                    P K I N C S R V                     *
               >149  *                                                        *
               >150  *             Michael J. Mahon - Nov 05, 2004            *
               >151  *                                                        *
               >152  *                   Copyright (c) 2004                   *
               >153  *                                                        *
               >154  *  Service machine 'rbuf+frm's request to send 2 bytes   *
               >155  *  at our 'rbuf+adr', then increment value by 'rbuf+len'.*
               >156  *                                                        *
               >157  *  The PEEKINC request serves as a "network atomic"      *
               >158  *  read-modify-write primitive for synchronization and   *
               >159  *  allocation operations.                                *
               >160  *                                                        *
               >161  *  PKINCSRV does the following steps:                    *
               >162  *     1. Save initial 2-byte value in ACK buffer         *
               >163  *        while incrementing the value by 'rbuf+len'      *
               >164  *     2. Send the ACK packet with data.                  *
               >165  *                                                        *
               >166  **********************************************************
               >167  
               >168  PKINCSRV mov16 rbuf+adr;address ; Set up data address
952C: AD 34 91 >168           lda   rbuf+adr   ; Move 2 bytes
952F: 85 FC    >168           sta   address    
9531: AD 35 91 >168           lda   1+rbuf+adr 
9534: 85 FD    >168           sta   1+address  
               >168           eom              
9536: A0 00    >169           ldy   #0         
9538: 18       >170           clc              
9539: B1 FC    >171  :movinc  lda   (address),y ; Move and Inc 2 bytes
953B: 99 2E 91 >172           sta   sbuf+len,y 
953E: 79 36 91 >173           adc   rbuf+len,y 
9541: 91 FC    >174           sta   (address),y 
9543: C8       >175           iny              
9544: 98       >176           tya              ; Don't disturb carry.
9545: 49 02    >177           eor   #2         ; Done?
9547: D0 F0    >178           bne   :movinc    ; -No, go again.
9549: 4C 00 98 >179           jmp   SENDACK    ; -Yes, send ACK with value.
 
                ===== Page 33 -  NADA.PRODOS - Nov. 17, 2004 =====
  
               >181  *--------------------------------------------------------*
               >182  *         Requester                     Server           *
               >183  *  ========================     =======================  *
               >184  *  POKE   REQ (addr,leng)  ====>                         *
               >185  *                          <==== POKE   ACK              *
               >186  *                    Data  ====>                         *
               >187  *                            :                           *
               >188  *                    Data  ====>                         *
               >189  *                          <==== POKE   DACK             *
               >190  *--------------------------------------------------------*
 
                ===== Page 34 -  NADA.PRODOS - Nov. 17, 2004 =====
  
               >194  **********************************************************
               >195  *                                                        *
               >196  *                     P O K E R E Q                      *
               >197  *                                                        *
               >198  *            Michael J. Mahon - May 11, 1996             *
               >199  *                 Revised April 19, 2004                 *
               >200  *                                                        *
               >201  *                Copyright (c) 1996, 2004                *
               >202  *                                                        *
               >203  *  Request machine 'sbuf+dst' to store 'sbuf+len' bytes  *
               >204  *  at its 'sbuf+adr', and send them from our location    *
               >205  *  'locaddr'.                                            *
               >206  *                                                        *
               >207  *  POKEREQ, like other requests, will retry the request  *
               >208  *  in case of error, up to 'maxreqrt' times.  If errors  *
               >209  *  persist, it will return with Carry set.               *
               >210  *                                                        *
               >211  *  POKEREQ does the following steps:                     *
               >212  *     1. Make the POKE request (and receive the ACK)     *
               >213  *     2. Send 'sbuf+len' bytes of data from 'locaddr'    *
               >214  *     3. Receive DATA ACK response                       *
               >215  *     4. Retry in case of error up to 'maxreqrt' times   *
               >216  *                                                        *
               >217  **********************************************************
               >218  
954C: A9 03    >219  POKEREQ  lda   #maxreqrt  ; Set request retry
954E: 8D 59 91 >220           sta   reqretry   ;  counter.
9551: A9 02    >221  :retry   lda   #r_POKE    ; Send POKE request.
9553: 20 00 96 >222           jsr   REQUEST    
9556: B0 1C    >223           bcs   :failed    
               >224           mov16 sbuf+len;length ; Set up 'length'
9558: AD 2E 91 >224           lda   sbuf+len   ; Move 2 bytes
955B: 85 FE    >224           sta   length     
955D: AD 2F 91 >224           lda   1+sbuf+len 
9560: 85 FF    >224           sta   1+length   
               >224           eom              
               >225           mov16 locaddr;address ; and 'address'
9562: AD 38 91 >225           lda   locaddr    ; Move 2 bytes
9565: 85 FC    >225           sta   address    
9567: AD 39 91 >225           lda   1+locaddr  
956A: 85 FD    >225           sta   1+address  
               >225           eom              
956C: 20 A0 99 >226           jsr   SENDLONG   ; Send multiple packets
956F: 20 6E 96 >227           jsr   RCVDACK    ; Receive DATA ACK packet.
9572: 90 06    >228           bcc   :done      ; -OK, return.
9574: CE 59 91 >229  :failed  dec   reqretry   ; Dec request retry count
9577: D0 D8    >230           bne   :retry     ; Try until OK or exhausted,
9579: 38       >231           sec              ;  then return with C set.
957A: 60       >232  :done    rts              
 
                ===== Page 35 -  NADA.PRODOS - Nov. 17, 2004 =====
  
               >236  **********************************************************
               >237  *                                                        *
               >238  *                     P O K E S R V                      *
               >239  *                                                        *
               >240  *            Michael J. Mahon - May 11, 1996             *
               >241  *                                                        *
               >242  *                   Copyright (c) 1996                   *
               >243  *                                                        *
               >244  *  Service machine 'rbuf+frm's request to poke 'rbuf+len'*
               >245  *  bytes of data to our 'rbuf+adr'.                      *
               >246  *                                                        *
               >247  *  POKESRV does the following steps:                     *
               >248  *     1. Send the ACK packet                             *
               >249  *     2. Receive multiple packets to 'rbuf+adr'          *
               >250  *     3. If data received OK, send DATA ACK packet       *
               >251  *                                                        *
               >252  **********************************************************
               >253  
957B: 20 00 98 >254  POKESRV  jsr   SENDACK    ; ACK the request.
               >255           mov16 rbuf+adr;address ; Set up data address
957E: AD 34 91 >255           lda   rbuf+adr   ; Move 2 bytes
9581: 85 FC    >255           sta   address    
9583: AD 35 91 >255           lda   1+rbuf+adr 
9586: 85 FD    >255           sta   1+address  
               >255           eom              
               >256           mov16 rbuf+len;length ;    and length...
9588: AD 36 91 >256           lda   rbuf+len   ; Move 2 bytes
958B: 85 FE    >256           sta   length     
958D: AD 37 91 >256           lda   1+rbuf+len 
9590: 85 FF    >256           sta   1+length   
               >256           eom              
9592: 20 BF 99 >257           jsr   RCVLONG    ; Receive long data message.
9595: B0 0A    >258           bcs   :err       ; Receive error.
               >259           delay 40         ; Allow requester to receive.
9597: A2 08    >259           ldx   #40/5      ; (5 cycles per iteration)
9599: CA       >259  ]delay   dex              
959A: D0 FD    >259           bne   ]delay     
               >259           eom              
959C: A9 03    >260           lda   #rm_DACK   ; Send DATA ACK
959E: 4C 02 98 >261           jmp   SENDRSP    ;   packet (and return).
               >262  
95A1: 60       >263  :err     rts              ; Return without data ACK.
 
                ===== Page 36 -  NADA.PRODOS - Nov. 17, 2004 =====
  
               >265  *--------------------------------------------------------*
               >266  *         Requester                     Server           *
               >267  *  ========================     =======================  *
               >268  *  BPOKE  REQ (addr,val)   ====>                         *
               >269  *                                 (Broadcast, No ACK)    *
               >270  *--------------------------------------------------------*
               >271  
               >274  **********************************************************
               >275  *                                                        *
               >276  *                    B P O K E R E Q                     *
               >277  *                                                        *
               >278  *            Michael J. Mahon - Nov. 04, 2004            *
               >279  *                 Revised Nov. 12, 2004                  *
               >280  *                                                        *
               >281  *                   Copyright (c) 2004                   *
               >282  *                                                        *
               >283  *  Broadcast request to all serving machines to store 2  *
               >284  *  bytes in 'sbuf+len' at address 'sbuf+adr'.            *
               >285  *                                                        *
               >286  *  BPOKE, unlike other requests, is broadcast, and so    *
               >287  *  is not acknowledged by any receiver.  To eliminate    *
               >288  *  the chance of collision, it holds the bus locked for  *
               >289  *  20ms after arbitration, then sends the request packet.*
               >290  *  This allows enough time for any colliding sender to   *
               >291  *  send its request and re-arbitrate while the bus is    *
               >292  *  locked, so that there is no contention when the BPOKE *
               >293  *  request is finally sent.                              *
               >294  *                                                        *
               >295  *  BPOKEREQ does the following steps:                    *
               >296  *     1. Arbitrate for and lock the bus                  *
               >297  *     2. Wait 20ms. while holding the bus locked.        *
               >298  *     3. Set up BPOKE request                            *
               >299  *     4. Send the BPOKE request packet.                  *
               >300  *                                                        *
               >301  **********************************************************
               >302  
95A2: 20 6A 97 >303  BPOKEREQ jsr   ARBTRATE   ; Arbitrate for & lock bus
               >304           dlyms 20         ; Let collisions resolve.
95A5: A0 14    >304           ldy   #20        ; Delay 1ms. per iteration
               >304  ]dly     delay 1020-4     ; Cycles per ms. - 4
95A7: A2 CB    >304           ldx   #1020-4/5  ; (5 cycles per iteration)
95A9: CA       >304  ]delay   dex              
95AA: D0 FD    >304           bne   ]delay     
               >304           eom              
95AC: 88       >304           dey              
95AD: D0 F8    >304           bne   ]dly       
               >304           eom              
95AF: A9 08    >305           lda   #r_BPOKE   ; Set up BPOKE request.
95B1: 8D 28 91 >306           sta   sbuf+req   
95B4: A9 01    >307           lda   #rm_REQ    
95B6: 8D 29 91 >308           sta   sbuf+mod   
95B9: A9 00    >309           lda   #0         ; Broadcast
95BB: 8D 2A 91 >310           sta   sbuf+dst   
95BE: 4C 11 98 >311           jmp   SENDCTL    ; Send the request.
 
                ===== Page 37 -  NADA.PRODOS - Nov. 17, 2004 =====
  
               >315  **********************************************************
               >316  *                                                        *
               >317  *                    B P O K E S R V                     *
               >318  *                                                        *
               >319  *            Michael J. Mahon - Nov 05, 2004             *
               >320  *                                                        *
               >321  *                   Copyright (c) 2004                   *
               >322  *                                                        *
               >323  *  Service machine 'rbuf+frm's request to poke 2 bytes   *
               >324  *  of data in 'rbuf+len' to our 'rbuf+adr'.              *
               >325  *                                                        *
               >326  *  BPOKESRV does the following:                          *
               >327  *     1. Move 'rbuf+len' to memory at 'rbuf+adr'.        *
               >328  *                                                        *
               >329  **********************************************************
               >330  
               >331  BPOKESRV mov16 rbuf+adr;address ; Set up pointer
95C1: AD 34 91 >331           lda   rbuf+adr   ; Move 2 bytes
95C4: 85 FC    >331           sta   address    
95C6: AD 35 91 >331           lda   1+rbuf+adr 
95C9: 85 FD    >331           sta   1+address  
               >331           eom              
95CB: A0 01    >332           ldy   #1         ; and move 2 bytes.
95CD: B9 36 91 >333  :move    lda   rbuf+len,y 
95D0: 91 FC    >334           sta   (address),y 
95D2: 88       >335           dey              
95D3: 10 F8    >336           bpl   :move      
95D5: 18       >337           clc              
95D6: 60       >338           rts              ; All done.
 
                ===== Page 38 -  NADA.PRODOS - Nov. 17, 2004 =====
  
               >340  *--------------------------------------------------------*
               >341  *         Requester                     Server           *
               >342  *  ========================     =======================  *
               >343  *  CALL   REQ (addr,A,X)   ====>                         *
               >344  *                          <==== CALL   ACK              *
               >345  *--------------------------------------------------------*
               >346  
               >349  **********************************************************
               >350  *                                                        *
               >351  *                     C A L L R E Q                      *
               >352  *                                                        *
               >353  *            Michael J. Mahon - May 11, 1996             *
               >354  *                 Revised March 05, 2004                 *
               >355  *                                                        *
               >356  *                Copyright (c) 1996, 2004                *
               >357  *                                                        *
               >358  *  Request machine 'sbuf+dst' to call a subroutine at    *
               >359  *  address 'sbuf+adr' with parameters A = 'sbuf+len' and *
               >360  *  X = 'sbuf+len+1'.                                     *
               >361  *                                                        *
               >362  *  CALLREQ, like other requests, will retry the request  *
               >363  *  in case of error, up to 'maxreqrt' times.  If errors  *
               >364  *  persist, it will return with Carry set.               *
               >365  *                                                        *
               >366  *  CALLREQ does the following steps:                     *
               >367  *     1. Make the CALL request (and receive the ACK)     *
               >368  *     2. Retry in case of error up to 'maxreqrt' times   *
               >369  *                                                        *
               >370  **********************************************************
               >371  
95D7: A9 03    >372  CALLREQ  lda   #maxreqrt  ; Set request retry
95D9: 8D 59 91 >373           sta   reqretry   ;  counter.
95DC: A9 03    >374  :retry   lda   #r_CALL    ; Send CALL request.
95DE: 20 00 96 >375           jsr   REQUEST    
95E1: 90 06    >376           bcc   :done      
95E3: CE 59 91 >377  :failed  dec   reqretry   ; Dec request retry count
95E6: D0 F4    >378           bne   :retry     ; Try until OK or exhausted,
95E8: 38       >379           sec              ;  then return with C set.
95E9: 60       >380  :done    rts              
 
                ===== Page 39 -  NADA.PRODOS - Nov. 17, 2004 =====
  
               >384  **********************************************************
               >385  *                                                        *
               >386  *                     C A L L S R V                      *
               >387  *                                                        *
               >388  *            Michael J. Mahon - May 11, 1996             *
               >389  *                 Revised March 27, 2004                 *
               >390  *                                                        *
               >391  *                Copyright (c) 1996, 2004                *
               >392  *                                                        *
               >393  *  Service machine 'rbuf+frm's request to call a         *
               >394  *  subroutine at our 'rbuf+adr' with parameters          *
               >395  *  A = 'rbuf+len' and X = 'rbuf+len+1'.  Flags are set   *
               >396  *  according to the value of A.                          *
               >397  *                                                        *
               >398  *  Note that when the subroutine returns, it returns to  *
               >399  *  whoever called SERVER.                                *
               >400  *                                                        *
               >401  *  CALLSRV does the following steps:                     *
               >402  *     1. Send the ACK packet                             *
               >403  *     2. Load parameters from 'rbuf+len' into A and X    *
               >404  *     3. Call subroutine at 'rbuf+adr'                   *
               >405  *                                                        *
               >406  **********************************************************
               >407  
95EA: 20 00 98 >408  CALLSRV  jsr   SENDACK    ; ACK the request.
               >409           mov16 rbuf+adr;address ; Move CALL address
95ED: AD 34 91 >409           lda   rbuf+adr   ; Move 2 bytes
95F0: 85 FC    >409           sta   address    
95F2: AD 35 91 >409           lda   1+rbuf+adr 
95F5: 85 FD    >409           sta   1+address  
               >409           eom              
95F7: AE 37 91 >410           ldx   rbuf+len+1 ; Set X parameter
95FA: AD 36 91 >411           lda   rbuf+len   ;  and A parameter, and
95FD: 6C FC 00 >412           jmp   (address)  ; Jump to requested address.
 
                ===== Page 40 -  NADA.PRODOS - Nov. 17, 2004 =====
  
               >416  **********************************************************
               >417  *                                                        *
               >418  *                     R E Q U E S T                      *
               >419  *                                                        *
               >420  *            Michael J. Mahon - April 20, 2004           *
               >421  *                  Revised Oct 12, 2004                  *
               >422  *                                                        *
               >423  *                Copyright (c) 1996, 2004                *
               >424  *                                                        *
               >425  *  Handle request protocol for the request in A & 'sbuf'.*
               >426  *                                                        *
               >427  *  Retry the protocol for up to 'reqtime' ms. (up to     *
               >428  *  'retrylim' times).  If successful, return with valid  *
               >429  *  response in 'rbuf' and Carry clear.                   *
               >430  *                                                        *
               >431  *  If request timed out, return with Carry set and A=0.  *
               >432  *                                                        *
               >433  *  If NAK received, return with Carry set and A>0.       *
               >434  *                                                        *
               >435  *  REQUEST performs the following steps:                 *
               >436  *     1. Complete control pkt in 'sbuf' (request in A)   *
               >437  *     2. Arbitrate for the use of the bus                *
               >438  *     3. Send the request specified in 'sbuf'            *
               >439  *     4. Receive the control response into 'rbuf'        *
               >440  *     5. Check 'rbuf' for a valid, expected response     *
               >441  *     6. Retry steps 2 to 5 up to 'retrylim' times       *
               >442  *     7. When ACKed, NAKed, or timed-out, return         *
               >443  *                                                        *
               >444  **********************************************************
               >445  
9600: 8D 28 91 >446  REQUEST  sta   sbuf+req   ; Store request code.
9603: A9 01    >447           lda   #rm_REQ    ; Put REQ in the
9605: 8D 29 91 >448           sta   sbuf+mod   ;  mod field, and
9608: AD 3A 91 >449           lda   retrylim   ;  init retry counter
960B: 8D 5A 91 >450           sta   retrycnt   
960E: AD 5A 91 >451  :retry   lda   retrycnt   ; Timed out?
9611: F0 59    >452           beq   :err       ; - Yes, return w/ C set, A=0
9613: CE 5A 91 >453           dec   retrycnt   ; Dec retry counter.
9616: 20 6A 97 >454           jsr   ARBTRATE   ; Arbitrate for & lock bus
9619: 20 11 98 >455           jsr   SENDCTL    ; Send request in 'sbuf'.
961C: 20 FB 98 >456           jsr   RCVCTL     ; Receive response in 'rbuf'.
961F: 90 19    >457           bcc   :ok        ; - clean packet received.
9621: 08       >458           php              ; Save flags,
               >459           dlyms reqdelay   ;  delay a few ms.
9622: A0 11    >459           ldy   #reqdelay  ; Delay 1ms. per iteration
               >459  ]dly     delay 1020-4     ; Cycles per ms. - 4
9624: A2 CB    >459           ldx   #1020-4/5  ; (5 cycles per iteration)
9626: CA       >459  ]delay   dex              
9627: D0 FD    >459           bne   ]delay     
               >459           eom              
9629: 88       >459           dey              
962A: D0 F8    >459           bne   ]dly       
               >459           eom              
962C: 28       >460           plp              ;   and restore flags.
962D: F0 DF    >461           beq   :retry     ; - no packet received.
               >462           inc16 ckerr      ; - count checksum errors.
962F: EE 3D 91 >462           inc   ckerr      ; Increment 16-bit word.
9632: D0 03    >462           bne   *+5        ; - No carry.
9634: EE 3E 91 >462           inc   ckerr+1    ; Propagate carry.
               >462           eom              
9637: 4C 0E 96 >463           jmp   :retry     ;    and try again...
               >464  
963A: AD 32 91 >465  :ok      lda   rbuf+dst   ; Message received, is
963D: CD 27 91 >466           cmp   self       ;  it for us?
9640: D0 1B    >467           bne   :proterr   ; - No, error.
9642: AD 2A 91 >468           lda   sbuf+dst   ; - Yes.  Is it from
9645: CD 33 91 >469           cmp   rbuf+frm   ;    our destination?
9648: D0 13    >470           bne   :proterr   ; - No.  Protocol error.
964A: AD 30 91 >471           lda   rbuf+req   ; - Yes.  Is it what
964D: CD 28 91 >472           cmp   sbuf+req   ;    we expected?
 
                ===== Page 41 -  NADA.PRODOS - Nov. 17, 2004 =====
 
9650: D0 0B    >473           bne   :proterr   ; - No, error.
9652: AD 31 91 >474           lda   rbuf+mod   ; - Yes, so far...
9655: C9 02    >475           cmp   #rm_ACK    ; Is it an ACK?
9657: F0 0F    >476           beq   :good      ; - Yes, valid response!
9659: C9 04    >477           cmp   #rm_NAK    ; Is it a NAK?
965B: F0 0D    >478           beq   :nakexit   ; -Yes, return w/ C set, A=1
               >479  :proterr inc16 errprot    ; - No, count protocol errors.
965D: EE 3B 91 >479           inc   errprot    ; Increment 16-bit word.
9660: D0 03    >479           bne   *+5        ; - No carry.
9662: EE 3C 91 >479           inc   errprot+1  ; Propagate carry.
               >479           eom              
9665: 4C 0E 96 >480           jmp   :retry     ;    and try again...
               >481  
9668: 18       >482  :good    clc              ; Signal good ACK
9669: 60       >483           rts              ;  and return.
               >484  
966A: A9 01    >485  :nakexit lda   #1         ; Signal NAK
966C: 38       >486  :err     sec              ; Signal error
966D: 60       >487           rts              ;  and return.
 
                ===== Page 42 -  NADA.PRODOS - Nov. 17, 2004 =====
  
               >491  **********************************************************
               >492  *                                                        *
               >493  *                     R C V D A C K                      *
               >494  *                                                        *
               >495  *            Michael J. Mahon - Apr 19, 2004             *
               >496  *                                                        *
               >497  *                   Copyright (c) 2004                   *
               >498  *                                                        *
               >499  *  Receive DATA ACK packet.  Require a good cksum,       *
               >500  *  addressed to us, response req = sent req.  If all OK, *
               >501  *  return with Carry clear, else with Carry set.         *
               >502  *                                                        *
               >503  **********************************************************
               >504  
966E: 20 FB 98 >505  RCVDACK  jsr   RCVCTL     ; Receive response packet.
9671: 90 0C    >506           bcc   :ok        ; -Clean packet received.
9673: F0 2B    >507           beq   :proterr   ; -Timed out.
               >508           inc16 ckerr      ; -Check sum error.
9675: EE 3D 91 >508           inc   ckerr      ; Increment 16-bit word.
9678: D0 03    >508           bne   *+5        ; - No carry.
967A: EE 3E 91 >508           inc   ckerr+1    ; Propagate carry.
               >508           eom              
967D: B0 2A    >509           bcs   :return    ; Return with Carry set.
               >510  
967F: AD 32 91 >511  :ok      lda   rbuf+dst   ; Is packet for us?
9682: CD 27 91 >512           cmp   self       
9685: D0 19    >513           bne   :proterr   ; -No, protocol error.
9687: AD 33 91 >514           lda   rbuf+frm   ; Was it sent by receiver?
968A: CD 2A 91 >515           cmp   sbuf+dst   
968D: D0 11    >516           bne   :proterr   ; -No, protocol error.
968F: AD 30 91 >517           lda   rbuf+req   ; Does it match sent req?
9692: CD 28 91 >518           cmp   sbuf+req   
9695: D0 09    >519           bne   :proterr   ; -No, protocol error.
9697: AD 31 91 >520           lda   rbuf+mod   ; Load request modifier
969A: C9 03    >521           cmp   #rm_DACK   ; Is it a DATA ACK?
969C: D0 02    >522           bne   :proterr   ; -No, protocol error.
969E: 18       >523           clc              ; -Yes, clear Carry
969F: 60       >524           rts              ;   and return.
               >525  
               >526  :proterr inc16 errprot    ; Tally protocol error
96A0: EE 3B 91 >526           inc   errprot    ; Increment 16-bit word.
96A3: D0 03    >526           bne   *+5        ; - No carry.
96A5: EE 3C 91 >526           inc   errprot+1  ; Propagate carry.
               >526           eom              
96A8: 38       >527           sec              ;  then return with C set.
96A9: 60       >528  :return  rts              
 
                ===== Page 43 -  NADA.PRODOS - Nov. 17, 2004 =====
  
                56           put   PUTMGETM   
               >1    **********************************************************
               >2    *                                                        *
               >3    *                    Message Server                      *
               >4    *                                                        *
               >5    *           Michael J. Mahon - April 20, 2004            *
               >6    *                 Revised Oct 13, 2004                   *
               >7    *                                                        *
               >8    *                  Copyright (c) 2004                    *
               >9    *                                                        *
               >10   *       Client Request Routines                          *
               >11   *         Put Message Request                            *
               >12   *         Get Message Request                            *
               >13   *                                                        *
               >14   *       Server Definitions                               *
               >15   *         Message Page Table                             *
               >16   *         Message Class Table                            *
               >17   *         Message Buffers (pages)                        *
               >18   *                                                        *
               >19   *       Server Routines (w/ Monitor)                     *
               >20   *         Put Message Server                             *
               >21   *         Get Message Server                             *
               >22   *                                                        *
               >23   *       Utility Routines                                 *
               >24   *         Look Up class in Message Table                 *
               >25   *                                                        *
               >26   **********************************************************
               >27   
               >28   *--------------------------------------------------------*
               >29   *         Requester                     Server           *
               >30   *  ========================     =======================  *
               >31   *  PUTMSG REQ (class,leng) ====>                         *
               >32   *         (lock)             :                           *
               >33   *                         (<==== PUTMSG NAK if no space) *
               >34   *                                                        *
               >35   *                          <==== PUTMSG ACK              *
               >36   *         Data < 256 bytes ====>                         *
               >37   *                          <==== PUTMSG DACK             *
               >38   *--------------------------------------------------------*
               >39   *  GETMSG REQ (class)      ====>                         *
               >40   *         (lock)             :                           *
               >41   *                         (<==== GETMSG NAK if no msg)   *
               >42   *                                                        *
               >43   *                          <==== GETMSG ACK (class,leng) *
               >44   *                          <==== Data < 256 bytes        *
               >45   *  GETMSG DACK             ====>                         *
               >46   *--------------------------------------------------------*
 
                ===== Page 44 -  NADA.PRODOS - Nov. 17, 2004 =====
  
               >49   **********************************************************
               >50   *                                                        *
               >51   *                     P U T M R E Q                      *
               >52   *                                                        *
               >53   *           Michael J. Mahon - April 17, 2004            *
               >54   *                                                        *
               >55   *                   Copyright (c) 2004                   *
               >56   *                                                        *
               >57   *  Request message server (at 'sbuf+dest') to accept a   *
               >58   *  message of class 'sbuf+adr' and length 'sbuf+len'     *
               >59   *  at our local address 'locaddr'.                       *
               >60   *                                                        *
               >61   *  PUTMREQ will retry the request in case of timeout or  *
               >62   *  checksum errors up to 'maxreqrt' times.  If errors    *
               >63   *  persist, it returns with C set and A=0.               *
               >64   *                                                        *
               >65   *  If the server NAKs the request for lack of space,     *
               >66   *  PUTMREQ returns with C set and A=1.                   *
               >67   *                                                        *
               >68   *  PUTMREQ does the following steps:                     *
               >69   *     1. Make the PUTMSG request                         *
               >70   *     2. If server NAKs, return with C set and A=1.      *
               >71   *     3. Send 'sbuf+len'-byte message from 'locaddr'     *
               >72   *     4. Receive DATA ACK packet                         *
               >73   *     5. Retry in case of error up to 'maxreqrt' times   *
               >74   *     6. If unsuccessful, return with C set and A=0.     *
               >75   *                                                        *
               >76   **********************************************************
               >77   
96AA: A9 03    >78   PUTMREQ  lda   #maxreqrt  ; Set request retry
96AC: 8D 59 91 >79            sta   reqretry   ;  counter.
96AF: A9 04    >80   :retry   lda   #r_PUTMSG  ; Send PUTMSG request.
96B1: 20 00 96 >81            jsr   REQUEST    
96B4: B0 1E    >82            bcs   :failed    
               >83            mov16 sbuf+len;length ; Set up 'length'
96B6: AD 2E 91 >83            lda   sbuf+len   ; Move 2 bytes
96B9: 85 FE    >83            sta   length     
96BB: AD 2F 91 >83            lda   1+sbuf+len 
96BE: 85 FF    >83            sta   1+length   
               >83            eom              
               >84            mov16 locaddr;address ; and 'address'
96C0: AD 38 91 >84            lda   locaddr    ; Move 2 bytes
96C3: 85 FC    >84            sta   address    
96C5: AD 39 91 >84            lda   1+locaddr  
96C8: 85 FD    >84            sta   1+address  
               >84            eom              
96CA: 20 A0 99 >85            jsr   SENDLONG   ; Send  message
96CD: 20 6E 96 >86            jsr   RCVDACK    ; Receive DATA ACK packet.
96D0: 90 0A    >87            bcc   :done      ; -All OK.
96D2: A9 00    >88            lda   #0         ; Not a NAK error
96D4: D0 05    >89   :failed  bne   :nakexit   
96D6: CE 59 91 >90   :cksumer dec   reqretry   ; Dec request retry count
96D9: D0 D4    >91            bne   :retry     ; Try until OK or exhausted,
96DB: 38       >92   :nakexit sec              ;  then return with C set.
96DC: 60       >93   :done    rts              
 
                ===== Page 45 -  NADA.PRODOS - Nov. 17, 2004 =====
  
               >95   **********************************************************
               >96   *                                                        *
               >97   *                     G E T M R E Q                      *
               >98   *                                                        *
               >99   *            Michael J. Mahon - April 19, 2004           *
               >100  *                                                        *
               >101  *                   Copyright (c) 2004                   *
               >102  *                                                        *
               >103  *  Request message server (at 'sbuf+dst') to deliver     *
               >104  *  the first message of class 'sbuf+adr' to our address  *
               >105  *  'locaddr', actual length in 'rbuf+len' after ACK.     *
               >106  *                                                        *
               >107  *  GETMREQ will retry the request in case of timeout or  *
               >108  *  checksum errors up to 'maxreqrt' times.  If errors    *
               >109  *  persist, it returns with C set and A=0.               *
               >110  *                                                        *
               >111  *  If the server NAKs the request because the message    *
               >112  *  queue is empty, GETMREQ returns with C set and A=1.   *
               >113  *                                                        *
               >114  *  GETMREQ does the following steps:                     *
               >115  *     1. Make the GETMSG request                         *
               >116  *     2. If server NAKs, return with C set and A=1.      *
               >117  *     3. Receive 'rbuf+len'-byte message to 'locaddr'    *
               >118  *     4. If no error, send DATA ACK packet               *
               >119  *     5. Retry in case of error up to 'maxreqrt' times   *
               >120  *     6. If unsuccessful, return with C set and A=0.     *
               >121  *                                                        *
               >122  **********************************************************
               >123  
96DD: A9 03    >124  GETMREQ  lda   #maxreqrt  ; Set request retry
96DF: 8D 59 91 >125           sta   reqretry   ;  counter.
96E2: A9 05    >126  :retry   lda   #r_GETMSG  ; Send GETMSG request.
96E4: 20 00 96 >127           jsr   REQUEST    
96E7: B0 23    >128           bcs   :failed    ; Timeout or no msg.
               >129           mov16 rbuf+len;length ; Set up 'length'
96E9: AD 36 91 >129           lda   rbuf+len   ; Move 2 bytes
96EC: 85 FE    >129           sta   length     
96EE: AD 37 91 >129           lda   1+rbuf+len 
96F1: 85 FF    >129           sta   1+length   
               >129           eom              
               >130           mov16 locaddr;address ; and 'address'
96F3: AD 38 91 >130           lda   locaddr    ; Move 2 bytes
96F6: 85 FC    >130           sta   address    
96F8: AD 39 91 >130           lda   1+locaddr  
96FB: 85 FD    >130           sta   1+address  
               >130           eom              
96FD: 20 BF 99 >131           jsr   RCVLONG    ; Receive segmented message
9700: B0 0C    >132           bcs   :err       ; Timeout or cksum err.
               >133           delay 40         ; Kill some time...
9702: A2 08    >133           ldx   #40/5      ; (5 cycles per iteration)
9704: CA       >133  ]delay   dex              
9705: D0 FD    >133           bne   ]delay     
               >133           eom              
9707: A9 03    >134           lda   #rm_DACK   ; -OK, send DATA ACK.
9709: 4C 02 98 >135           jmp   SENDRSP    ;   and return w/ C clear.
               >136  
970C: D0 05    >137  :failed  bne   :nak       ; Server has no message.
970E: CE 59 91 >138  :err     dec   reqretry   ; Cksum or timeout; dec count.
9711: D0 CF    >139           bne   :retry     ; Try until OK or exhausted,
9713: 38       >140  :nak     sec              ;  then return with C set.
9714: 60       >141           rts              
 
                ===== Page 46 -  NADA.PRODOS - Nov. 17, 2004 =====
  
                57           put   SENDRCV    
               >1    **********************************************************
               >2    *                                                        *
               >3    *                LOW-LEVEL PACKET FORMAT                 *
               >4    *                                                        *
               >5    * Start of packet:                                       *
               >6    *                                                        *
               >7    *  --//---+---------+      +---------+-----+-----+-//->  *
               >8    *  Locked |   ONE   | ZERO |   ONE   |Bit7 |Bit6 |       *
               >9    *  or Idle|   36cy  | 10cy |   17cy  | 9cy | 9cy |       *
               >10   *  --//---+         +------+         +-----+-----+-//->  *
               >11   *         |                          |                   *
               >12   *         |<-------- Start --------->|<-- 8 data --//->  *
               >13   *                    Signal                bits          *
               >14   *                    (63cy)               (75cy)         *
               >15   *                                                        *
               >16   *  (Note: Bit4 data is lengthened by 3 cyc, to 12 cyc.)  *
               >17   *                                                        *
               >18   * Interbyte separator:                                   *
               >19   *                                                        *
               >20   *  >-//-----+-----+-------+           +-----+------//->  *
               >21   *           |Bit0 |  ONE  |    ZERO   |Bit7 |            *
               >22   *           | 9cy |  12cy |    19cy   | 9cy |            *
               >23   *  >-//-----+-----+       +-----------+-----+------//->  *
               >24   *                 |       |           |                  *
               >25   *  >-//- 8 data ->|     Servo         |<- 8 data --//->  *
               >26   *         bits    |   transition      |    bits          *
               >27   *                 |                   |                  *
               >28   *                 |<--- Interbyte --->|                  *
               >29   *                       separator                        *
               >30   *                         (31cy)                         *
               >31   *                                                        *
               >32   * Checkbyte separator:                                   *
               >33   *                                                        *
               >34   * >-// --+-----+-------+                 +-----+---//->  *
               >35   *        |Bit0 |  ONE  |      ZERO       |Bit7 |         *
               >36   *        | 9cy |  12cy |      26cy       | 9cy |         *
               >37   * >-//---+-----+       +-----------------+-----+---//->  *
               >38   *              |       |                 |               *
               >39   * >-//- data ->|     Servo               |<- data -//->  *
               >40   *       bits   |   transition            |   bits        *
               >41   *   (last data)|                         |(checkbyte)    *
               >42   *              |<------ Extended ------->|               *
               >43   *                      check byte                        *
               >44   *                       separator                        *
               >45   *                        (38cy)                          *
               >46   *                                                        *
               >47   * Packet end:                                            *
               >48   *                                                        *
               >49   *  >-//--+-----+-----+-------+                           *
               >50   *        |Bit1 |Bit0 |  ONE  |         (Idle)            *
               >51   *        | 9cy | 9cy |  12cy |                           *
               >52   *  >-//--+-----+-----+       +---------------------//->  *
               >53   *                    |                                   *
               >54   *  >-//--- End of -->|                                   *
               >55   *        checkbyte                                       *
               >56   *                                                        *
               >57   **********************************************************
 
                ===== Page 47 -  NADA.PRODOS - Nov. 17, 2004 =====
  
               >60   **********************************************************
               >61   *                                                        *
               >62   *                    M O N I T O R                       *
               >63   *                                                        *
               >64   *            Michael J. Mahon - May 26, 2004             *
               >65   *                 Revised Nov 10, 2004                   *
               >66   *                                                        *
               >67   *                  Copyright (c) 2004                    *
               >68   *                                                        *
               >69   *  Receive the first 8 bytes of each packet into buffer  *
               >70   *  in memory, together with its checksum residue.        *
               >71   *                                                        *
               >72   *  RCVPKT timeouts are recorded as 2-byte $DEAD marks    *
               >73   *  and are temporarily increased to 20ms.                *
               >74   *                                                        *
               >75   **********************************************************
               >76   
               >77   bufstrt  equ   $2000      ; Start of monitor buffer
               >81   bufend   equ   entry-$100 ; Ending page of monitor buffer
               >83   monlen   equ   lenctl     ; Monitor record data length
               >84   toflg1   equ   $DE        ; Timeout flag byte 1
               >85   toflg2   equ   $AD        ; Timeout flag byte 2
               >86   
               >87   MONITOR  mov16 #bufstrt;ptr ; Set start of buffer
9715: A9 00    >87            lda   #bufstrt   ; Move 2 bytes
9717: 85 ED    >87            sta   ptr        
9719: A9 20    >87            lda   #bufstrt/$100 ; high byte of immediate
971B: 85 EE    >87            sta   1+ptr      
               >87            eom              
971D: A2 08    >88            ldx   #idleto    ; Set RCVPKT timeout
971F: 8E 57 91 >89            stx   tolim      ;  to 20 ms.
9722: A2 08    >90   :waitgap ldx   #gapwait   ; Wait for interpacket gap.
9724: CD E8 C0 >91            cmp   zipslow    ; Slow Zip Chip to 1MHz.
9727: AC 62 C0 >92            ldy   drecv      ; Sample network state.
972A: 98       >93   :wait    tya              
972B: 4D 62 C0 >94            eor   drecv      ; Net unchanged?
972E: 30 F2    >95            bmi   :waitgap   ; -No, start over.
9730: CA       >96            dex              ; -Yes, count down
9731: D0 F7    >97            bne   :wait      ;   until satisfied.
9733: A2 08    >98   :next    ldx   #monlen    ; Set length
9735: 20 05 99 >99            jsr   RCVPTR     ;  to receive...
9738: A0 08    >100           ldy   #monlen    ; Point to cksum residue
973A: AA       >101           tax              ; Save cksum residue
973B: 90 0B    >102           bcc   :store     ; -Good packet.
973D: D0 09    >103           bne   :store     ; -Cksum error.
973F: A9 DE    >104           lda   #toflg1    ; -Timeout.  Flag
9741: A0 00    >105           ldy   #0         ;   it in buffer.
9743: 91 ED    >106           sta   (ptr),y    
9745: A9 AD    >107           lda   #toflg2    
9747: C8       >108           iny              
9748: 91 ED    >109  :store   sta   (ptr),y    ; Store byte in buffer
974A: 98       >110           tya              ; Inc ptr by record
974B: 38       >111           sec              ;  length + 1.
974C: 65 ED    >112           adc   ptr        
974E: 85 ED    >113           sta   ptr        
9750: A9 00    >114           lda   #0         
9752: 65 EE    >115           adc   ptr+1      
9754: 85 EE    >116           sta   ptr+1      
9756: C9 90    >117           cmp   #>bufend   ; Buffer full?
9758: B0 0A    >118           bcs   :end       ; -Yes, stop.
975A: AD 00 C0 >119           lda   keybd      ; Key pressed?
975D: 30 05    >120           bmi   :end       ; -Yes, stop.
975F: 8A       >121           txa              ; Recover cksum residue
9760: F0 D1    >122           beq   :next      ; -Good, receive next.
9762: D0 BE    >123           bne   :waitgap   ; -Bad, wait next gap.
               >124  
9764: A2 01    >125  :end     ldx   #reqto     ; Restore timeout to
9766: 8E 57 91 >126           stx   tolim      ;  minimum arb time.
9769: 60       >127           rts              
 
                ===== Page 48 -  NADA.PRODOS - Nov. 17, 2004 =====
  
               >130  **********************************************************
               >131  *                                                        *
               >132  *                    A R B T R A T E                     *
               >133  *                                                        *
               >134  *             Michael J. Mahon - May 1, 1996             *
               >135  *                 Revised Nov 05, 2004                   *
               >136  *                                                        *
               >137  *                   Copyright (c) 1996                   *
               >138  *                                                        *
               >139  *  Waits until bus has been idle for 'arbtime' plus      *
               >140  *  machine id # * 22 cycles, then locks bus and sends    *
               >141  *  the request control packet.                           *
               >142  *                                                        *
               >143  **********************************************************
               >144  
976A: AE 56 91 >145  ARBTRATE ldx   arbxv      ; Set arbitration wait.
976D: CD E8 C0 >146           cmp   zipslow    ; Zip Chip to 1MHz mode.
9770: 2C 62 C0 >147  :waitidl bit   drecv      ; Wait for idle bus.
9773: 30 F5    >148           bmi   ARBTRATE   ; Restart timing.
9775: CA       >149           dex              
9776: D0 F8    >150           bne   :waitidl   ; ...not yet.
9778: 8D 5B C0 >151           sta   dsend+1    ; Got it!  Lock the bus
977B: 60       >152           rts              ;  and return.
 
                ===== Page 49 -  NADA.PRODOS - Nov. 17, 2004 =====
  
               >154           align 256        ; Align to next page.
977C: 00 00 00 >154           ds    *-1/256*256+256-* 
               >154           eom              
               >155                            ; (Timing-critical code)
               >156  
               >157  **********************************************************
               >158  *                                                        *
               >159  *                     S E N D P K T                      *
               >160  *                                                        *
               >161  *           Michael J. Mahon - April 15, 1996            *
               >162  *                 Revised Oct 12, 2004                   *
               >163  *                                                        *
               >164  *             Copyright (c) 1996, 2003, 2004             *
               >165  *                                                        *
               >166  *  Sends (X) bytes (1..256) starting at (A,Y) to the     *
               >167  *  currently selected machine(s).                        *
               >168  *                                                        *
               >169  *  SENDPKT does the following steps:                     *
               >170  *     1. Put Zip Chip in 'slow mode' for >38,000 cycles  *
               >171  *     2. Send start signal: 36 cyc ONE, 10 ZERO, 17 ONE. *
               >172  *     3. Send (X) bytes (at 106 cycles/byte)             *
               >173  *     4. Send one check byte (+7 extra byte sep. cycles) *
               >174  *     5. Returns with Carry clear.                       *
               >175  *                                                        *
               >176  *  SENDCTL performs a SENDPKT on the control packet      *
               >177  *  send buffer 'sbuf'.                                   *
               >178  *                                                        *
               >179  *  SENDRSP builds a packet specified by A in 'sbuf'      *
               >180  *  for the request in 'rbuf', then sends it.             *
               >181  *                                                        *
               >182  *  SENDACK builds an ACK packet in 'sbuf' for the        *
               >183  *  request in 'rbuf', then sends it.                     *
               >184  *                                                        *
               >185  *  To obtain maximum sending speed (9 cycles/bit), the   *
               >186  *  actual sending code is unrolled into two parts, one   *
               >187  *  that sends the four high bits, and one that sends the *
               >188  *  four low bits.  This division is necessary to permit  *
               >189  *  relative branches to "cover" the code.  This split    *
               >190  *  requires an extra branch between sending bit 4 and    *
               >191  *  sending bit 3, which lengthens bit 4 from 9 to 12     *
               >192  *  cycles.                                               *
               >193  *                                                        *
               >194  **********************************************************
               >195  
9800: A9 02    >196  SENDACK  lda   #rm_ACK    ; Build an ACK packet
9802: 8D 29 91 >197  SENDRSP  sta   sbuf+mod   ; Store modifier in 'sbuf'
9805: AD 30 91 >198           lda   rbuf+req   ; Same code as request
9808: 8D 28 91 >199           sta   sbuf+req   ;  code.
980B: AD 33 91 >200           lda   rbuf+frm   
980E: 8D 2A 91 >201           sta   sbuf+dst   ; Destination (= requester)
9811: A9 28    >202  SENDCTL  lda   #<sbuf     ; Control pkt send buffer
9813: A0 91    >203           ldy   #>sbuf     
9815: A2 08    >204           ldx   #lenctl    
9817: CD E8 C0 >206  SENDPKT  cmp   zipslow    ; Slow Zip Chip for packet.
981A: 8D 5B C0 >210           sta   dsend+1    ; Send start signal ONE
981D: 85 ED    >211           sta   ptr        ; A = start address lo
981F: 84 EE    >212           sty   ptr+1      ; Y = start address hi
9821: 86 EB    >213           stx   leng       ; X = length: 1..256 (0=256)
9823: 86 EC    >214           stx   ckbyte     ; Seed ckbyte with length.
9825: A2 00    >215           ldx   #0         ; X = 0 for abs,X addressing
9827: A0 00    >216           ldy   #0         ; Y = ptr to next data byte
9829: A9 01    >217           lda   #1         ; Set flag to
982B: 8D 58 91 >218           sta   sendck     ;  send ckbyte at end.
982E: 18       >219           clc              ; Ensure C clear at exit
982F: 08       >220           php              ; Save interrupt state
9830: 78       >221           sei              ;  and disable interrupts.
9831: 8D 5A C0 >222           sta   dsend+0    ; Begin a 10-cycle ZERO.
9834: EA       >223           nop              
9835: EA       >224           nop              
9836: EA       >225           nop              
 
                ===== Page 50 -  NADA.PRODOS - Nov. 17, 2004 =====
 
9837: 8D 5B C0 >226           sta   dsend+1    ; Start a 17-cycle ONE
983A: 4C 9F 98 >227           jmp   :sendata   
               >228  
983D: 8D 5A C0 >229  :bit00   sta   dsend+0    ; Send ZERO (4 cyc)
9840: 90 4D    >230           bcc   :nxbyte    ; This byte is finished.
               >231  
9842: 8D 5A C0 >232  :bit10   sta   dsend+0    ; Send ZERO (4 cyc)
9845: 2A       >233           rol              ; Bit 0 to Carry
9846: 90 F5    >234           bcc   :bit00     ; Handle zero
9848: 9D 5B C0 >235           sta   dsend+1,x  ; Send ONE (5 cyc)
984B: B0 42    >236           bcs   :nxbyte    ; This byte is finished.
               >237  
984D: 8D 5A C0 >238  :bit20   sta   dsend+0    ; Send ZERO (4 cyc)
9850: 2A       >239           rol              ; Bit 1 to Carry
9851: 90 EF    >240           bcc   :bit10     ; Handle zero
9853: 9D 5B C0 >241           sta   dsend+1,x  ; Send ONE (5 cyc)
9856: 2A       >242           rol              ; Bit 0 to Carry
9857: 90 E4    >243           bcc   :bit00     ; Handle zero
9859: 9D 5B C0 >244           sta   dsend+1,x  ; Send ONE (5 cyc)
985C: B0 31    >245           bcs   :nxbyte    ; This byte is finished.
               >246  
985E: 8D 5A C0 >247  :bit30   sta   dsend+0    ; Send ZERO (4 cyc)
9861: 2A       >248           rol              ; Bit 2 to Carry
9862: 90 E9    >249           bcc   :bit20     ; Handle zero
9864: 9D 5B C0 >250           sta   dsend+1,x  ; Send ONE (5 cyc)
9867: 2A       >251           rol              ; Bit 1 to Carry
9868: 90 D8    >252           bcc   :bit10     ; Handle zero
986A: 9D 5B C0 >253           sta   dsend+1,x  ; Send ONE (5 cyc)
986D: 2A       >254           rol              ; Bit 0 to Carry
986E: 90 CD    >255           bcc   :bit00     ; Handle zero
9870: 9D 5B C0 >256           sta   dsend+1,x  ; Send ONE (5 cyc)
9873: B0 1A    >257           bcs   :nxbyte    ; This byte is finished.
               >258  
9875: 2A       >259  :sendlo  rol              ; Bit 3 to Carry
9876: 90 E6    >260           bcc   :bit30     ; Handle zero
9878: 9D 5B C0 >261           sta   dsend+1,x  ; Send ONE (5 cyc)
987B: 2A       >262           rol              ; Bit 2 to Carry
987C: 90 CF    >263           bcc   :bit20     ; Handle zero
987E: 9D 5B C0 >264           sta   dsend+1,x  ; Send ONE (5 cyc)
9881: 2A       >265           rol              ; Bit 1 to Carry
9882: 90 BE    >266           bcc   :bit10     ; Handle zero
9884: 9D 5B C0 >267           sta   dsend+1,x  ; Send ONE (5 cyc)
9887: 2A       >268           rol              ; Bit 0 to Carry
9888: 90 B3    >269           bcc   :bit00     ; Handle zero
988A: 9D 5B C0 >270           sta   dsend+1,x  ; Send ONE (5 cyc)
988D: B0 00    >271           bcs   :nxbyte    ; This byte is finished.
               >272  
988F: 2A       >273  :nxbyte  rol              ; Restore A = data for cksum
9890: 8D 5B C0 >274           sta   dsend+1    ; Start 12-cycle ONE.
9893: 45 EC    >275           eor   ckbyte     ; Compute checksum
9895: 85 EC    >276           sta   ckbyte     ;  and save it.
9897: C8       >277           iny              ; Increment data pointer
9898: 8D 5A C0 >278           sta   dsend+0    ; Send ZERO (servo transition)
989B: C4 EB    >279           cpy   leng       ; Done?
989D: F0 54    >280           beq   :done      ;  -yes, check end.
989F: B1 ED    >281  :sendata lda   (ptr),y    ; Get next byte (5/6 cyc)
98A1: 2A       >282  :senda   rol              ; Bit 7 to Carry
98A2: 90 17    >283           bcc   :bit70     ; Handle zero
98A4: 9D 5B C0 >284           sta   dsend+1,x  ; Send ONE (5 cyc)
98A7: 2A       >285           rol              ; Bit 6 to Carry
98A8: 90 28    >286           bcc   :bit60     ; Handle zero
98AA: 9D 5B C0 >287           sta   dsend+1,x  ; Send ONE (5 cyc)
98AD: 2A       >288           rol              ; Bit 5 to Carry
98AE: 90 33    >289           bcc   :bit50     ; Handle zero
98B0: 9D 5B C0 >290           sta   dsend+1,x  ; Send ONE (5 cyc)
98B3: 2A       >291           rol              ; Bit 4 to Carry
98B4: 90 38    >292           bcc   :bit40     ; Handle zero
98B6: 9D 5B C0 >293           sta   dsend+1,x  ; Send ONE (5 cyc)
98B9: B0 BA    >294           bcs   :sendlo    ; Send low 4 bits.
               >295  
 
                ===== Page 51 -  NADA.PRODOS - Nov. 17, 2004 =====
 
98BB: 8D 5A C0 >296  :bit70   sta   dsend+0    ; Send ZERO (4 cyc)
98BE: 2A       >297           rol              ; Bit 6 to Carry
98BF: 90 11    >298           bcc   :bit60     ; Handle zero
98C1: 9D 5B C0 >299           sta   dsend+1,x  ; Send ONE (5 cyc)
98C4: 2A       >300           rol              ; Bit 5 to Carry
98C5: 90 1C    >301           bcc   :bit50     ; Handle zero
98C7: 9D 5B C0 >302           sta   dsend+1,x  ; Send ONE (5 cyc)
98CA: 2A       >303           rol              ; Bit 4 to Carry
98CB: 90 21    >304           bcc   :bit40     ; Handle zero
98CD: 9D 5B C0 >305           sta   dsend+1,x  ; Send ONE (5 cyc)
98D0: B0 A3    >306           bcs   :sendlo    ; Send low 4 bits.
               >307  
98D2: 8D 5A C0 >308  :bit60   sta   dsend+0    ; Send ZERO (4 cyc)
98D5: 2A       >309           rol              ; Bit 5 to Carry
98D6: 90 0B    >310           bcc   :bit50     ; Handle zero
98D8: 9D 5B C0 >311           sta   dsend+1,x  ; Send ONE (5 cyc)
98DB: 2A       >312           rol              ; Bit 4 to Carry
98DC: 90 10    >313           bcc   :bit40     ; Handle zero
98DE: 9D 5B C0 >314           sta   dsend+1,x  ; Send ONE (5 cyc)
98E1: B0 92    >315           bcs   :sendlo    ; Send low 4 bits.
               >316  
98E3: 8D 5A C0 >317  :bit50   sta   dsend+0    ; Send ZERO (4 cyc)
98E6: 2A       >318           rol              ; Bit 4 to Carry
98E7: 90 05    >319           bcc   :bit40     ; Handle zero
98E9: 9D 5B C0 >320           sta   dsend+1,x  ; Send ONE (5 cyc)
98EC: B0 87    >321           bcs   :sendlo    ; Send low 4 bits.
               >322  
98EE: 8D 5A C0 >323  :bit40   sta   dsend+0    ; Send ZERO (4 cyc)
98F1: 90 82    >324           bcc   :sendlo    ; Send low 4 bits.
               >325  
98F3: 88       >326  :done    dey              ; Prepare to send ckbyte
98F4: CE 58 91 >327           dec   sendck     ; Ckbyte flag set?
98F7: F0 A8    >328           beq   :senda     ; -Yes, send ckbyte.
98F9: 28       >329           plp              ; -No, restore int state
98FA: 60       >330  :exit    rts              ;   and return with C clear.
 
                ===== Page 52 -  NADA.PRODOS - Nov. 17, 2004 =====
  
               >332  **********************************************************
               >333  *                                                        *
               >334  *                      R C V P K T                       *
               >335  *                                                        *
               >336  *           Michael J. Mahon - April 15, 1996            *
               >337  *                 Revised Oct 13, 2004                   *
               >338  *                                                        *
               >339  *             Copyright (c) 1996, 2003, 2004             *
               >340  *                                                        *
               >341  *  Receives (X) bytes (1..256) starting at (A,Y) from    *
               >342  *  the sending machine.                                  *
               >343  *                                                        *
               >344  *  If no packet is detected within the minimum arb time  *
               >345  *  plus 'tolim'-1 times 2.8ms, it returns with carry set *
               >346  *  and A = 0.                                            *
               >347  *                                                        *
               >348  *  If packet is received, but checksum doesn't compare,  *
               >349  *  it returns with carry set and A <> 0.                 *
               >350  *                                                        *
               >351  *  RCVPKT does the following steps:                      *
               >352  *     1. Detect 'start signal' ONE                       *
               >353  *     2. Put Zip Chip in 'slow mode' for >38,000 cycles  *
               >354  *     3. Sync to middle 6 cycles of data cells           *
               >355  *     3. Receive (X) bytes (at 108 +0/-4 cycles/byte)    *
               >356  *     4. Receive check byte and verify correctness       *
               >357  *                                                        *
               >358  *  RCVCTL performs a RCVPKT to the control packet        *
               >359  *  receive buffer 'rbuf'.                                *
               >360  *                                                        *
               >361  *  RCVPTR performs a RCVPKT to the address in 'ptr' with *
               >362  *  length (X).                                           *
               >363  *                                                        *
               >364  **********************************************************
               >365  *                                                        *
               >366  *                 Implementation Note                    *
               >367  *                                                        *
               >368  *  RCVPKT maintains synchronization with the data stream *
               >369  *  by using a "digital PLL" technique.  The RCVPKT byte  *
               >370  *  loop is 2 cycles longer than the send loop.  When     *
               >371  *  RCVPKT samples the servo transition and finds that it *
               >372  *  has already happened, it subtracts 4 cycles from the  *
               >373  *  loop time, bringing the loop back into optimal sync.  *
               >374  *                                                        *
               >375  *  The effect is to keep the data sampling window on the *
               >376  *  2nd to 7th cycle of 8 stable data cycles, in spite of *
               >377  *  the send loop and receive loop buffers crossing pages *
               >378  *  at different points in a packet and speed variation   *
               >379  *  on the sending or receiving machines of +/- 1% clock  *
               >380  *  frequency relative to each other.                     *
               >381  *                                                        *
               >382  **********************************************************
               >383  
98FB: A9 30    >384  RCVCTL   lda   #<rbuf     ; Receive control pkt to 'rbuf'
98FD: A0 91    >385           ldy   #>rbuf     
98FF: A2 08    >386           ldx   #lenctl    
9901: 85 ED    >387  RCVPKT   sta   ptr        ; A = buf address lo
9903: 84 EE    >388           sty   ptr+1      ; Y = buf address hi
9905: 86 EB    >389  RCVPTR   stx   leng       ; X = length 1..256 (0=>256)
9907: 86 EC    >390           stx   ckbyte     ; Seed 'ckbyte' with length
9909: AC 57 91 >391           ldy   tolim      ; Wait <= (tolim-1) * 2.8ms.
990C: A2 5C    >392           ldx   #arbx      ;  plus minimum arb time.
990E: 08       >393           php              ; Save interrupt state
990F: 78       >394           sei              ;  and disable interrupts.
9910: CD E8 C0 >395           cmp   zipslow    ; Slow any Zip Chip to 1 MHz.
9913: 2C 62 C0 >396  :waitstr bit   drecv      ; Wait for starting ONE.
9916: 30 09    >397           bmi   :gotit     
9918: CA       >398           dex              ; (inner loop is 11 cycles)
9919: D0 F8    >399           bne   :waitstr   ; Keep waiting...
991B: 88       >403           dey              ; (outer loop is 2820 cycles)
991C: D0 F5    >404           bne   :waitstr   ; Loop for 'timeout' ms.
 
                ===== Page 53 -  NADA.PRODOS - Nov. 17, 2004 =====
 
991E: 98       >405           tya              ; Signal timeout (A = 0)
991F: F0 7B    >406           beq   :err       ;  and return with C set.
               >407  
9921: CD E8 C0 >408  :gotit   cmp   zipslow    ; Slow Zip Chip for packet.
9924: 2C 62 C0 >409  :wait0   bit   drecv      ; Wait for 10-cycle ZERO
9927: 30 FB    >410           bmi   :wait0     ;  (Coarse sync: d = 7 cyc)
9929: 2C 62 C0 >411           bit   drecv      ; Read fine sync (d = 4 cyc)
992C: 30 02    >412           bmi   :late      ; - Late, make up 3 cyc
992E: D5 00    >413           cmp   0,x        ; - Early, delay 6 tot
9930: A2 FF    >414  :late    ldx   #px        ; (Set X to force page crossing)
9932: A0 00    >415           ldy   #0         ; Initialize ptr = 0.
9934: 48       >416           pha              ; Delay 9 cycles
9935: 68       >417           pla              
9936: EA       >418           nop              
               >419  *-------------------------; <-- start of 9-cycle/bit code
9937: 3E 63 BF >420  :nxbyte  rol   drecv-px,x ; C <-- data (on cycle 5 of 7)
993A: 2A       >421           rol              ; Shift bit 7 in.
993B: 3E 63 BF >422           rol   drecv-px,x ; C <-- bit 6
993E: 2A       >423           rol              
993F: 3E 63 BF >424           rol   drecv-px,x ; C <-- bit 5
9942: 2A       >425           rol              
9943: 3E 63 BF >426           rol   drecv-px,x ; C <-- bit 4
9946: 2A       >427           rol              
9947: C5 00    >428           cmp   0          ; (Bit 4 is stretched 3 cycles)
9949: 3E 63 BF >429           rol   drecv-px,x ; C <-- bit 3
994C: 2A       >430           rol              
994D: 3E 63 BF >431           rol   drecv-px,x ; C <-- bit 2
9950: 2A       >432           rol              
9951: 3E 63 BF >433           rol   drecv-px,x ; C <-- bit 1
9954: 2A       >434           rol              
9955: 3E 63 BF >435           rol   drecv-px,x ; C <-- bit 0
9958: 2A       >436           rol              
               >437  *-------------------------; <-- end of 9-cycle/bit code
9959: 91 ED    >438           sta   (ptr),y    ; Put byte in buffer (5/6 cyc)
995B: 4D EC 00 >439           eora  ckbyte     ; Compute checksum (4 cyc)
995E: 2C 62 C0 >440           bit   drecv      ; Sample servo transition.
9961: 10 03    >441           bpl   :late2     ; - Late, delay only 3 cyc.
9963: EA       >442           nop              ; - Early, delay net
9964: 30 00    >443           bmi   :late2     ;    of 7 cyc.
9966: 8D EC 00 >444  :late2   staa  ckbyte     ; Save check byte (4 cyc)
9969: C8       >445           iny              ;  and advance it.
996A: CC EB 00 >446           cpya  leng       ; Done yet? (4 cyc)
996D: D0 C8    >447           bne   :nxbyte    ; - no.
996F: 48       >448           pha              ; - yes, delay
9970: 68       >449           pla              ;    9
9971: EA       >450           nop              ;     cycles...
               >451  *-------------------------; Read check byte
9972: 3E 63 BF >452           rol   drecv-px,x ; C <-- data (on cycle 5 of 7)
9975: 2A       >453           rol              ; Shift bit 7 in.
9976: 3E 63 BF >454           rol   drecv-px,x ; C <-- bit 6
9979: 2A       >455           rol              
997A: 3E 63 BF >456           rol   drecv-px,x ; C <-- bit 5
997D: 2A       >457           rol              
997E: 3E 63 BF >458           rol   drecv-px,x ; C <-- bit 4
9981: 2A       >459           rol              
9982: C5 00    >460           cmp   0          ; (Bit 4 is stretched 3 cycles)
9984: 3E 63 BF >461           rol   drecv-px,x ; C <-- bit 3
9987: 2A       >462           rol              
9988: 3E 63 BF >463           rol   drecv-px,x ; C <-- bit 2
998B: 2A       >464           rol              
998C: 3E 63 BF >465           rol   drecv-px,x ; C <-- bit 1
998F: 2A       >466           rol              
9990: 3E 63 BF >467           rol   drecv-px,x ; C <-- bit 0
9993: 2A       >468           rol              
               >469  *-------------------------;
9994: 45 EC    >470           eor   ckbyte     ; Check byte = sum?
9996: D0 04    >471           bne   :err       ; -no, error.
9998: 28       >472           plp              ; -yes, restore int state
9999: AA       >473           tax              ;   set Z flag from A
999A: 18       >474           clc              ;    and return.
 
                ===== Page 54 -  NADA.PRODOS - Nov. 17, 2004 =====
 
999B: 60       >475           rts              
               >476  
999C: 28       >477  :err     plp              ; Restore interrupt state,
999D: 38       >478           sec              ;  set carry,
999E: AA       >479           tax              ;   set Z flag from A,
999F: 60       >480           rts              ;    and return...
 
                ===== Page 55 -  NADA.PRODOS - Nov. 17, 2004 =====
  
               >483  **********************************************************
               >484  *                                                        *
               >485  *                    S E N D L O N G                     *
               >486  *                                                        *
               >487  *             Michael J. Mahon - May 5, 1996             *
               >488  *                                                        *
               >489  *                   Copyright (c) 1996                   *
               >490  *                                                        *
               >491  *  SENDLONG sends 'length' bytes from 'address' to the   *
               >492  *  currently selected machine(s).                        *
               >493  *                                                        *
               >494  *  It segments a "message" longer than 256 bytes into a  *
               >495  *  series of 256-byte packets, plus a final packet       *
               >496  *  with the remainder of the data.  Each message packet  *
               >497  *  is sent with 'SENDPKT'.                               *
               >498  *                                                        *
               >499  *  SENDLONG does not detect any errors.                  *
               >500  *                                                        *
               >501  **********************************************************
               >502  
99A0: A5 FF    >503  SENDLONG lda   length+1   ; How many 256-byte pages?
99A2: F0 0F    >504           beq   :short     ; - None, just a short pkt.
99A4: A2 00    >505  :loop    ldx   #0         ; Set 256 byte packet.
99A6: A5 FC    >506           lda   address    ;  and point to
99A8: A4 FD    >507           ldy   address+1  ;   data buffer.
99AA: 20 17 98 >508           jsr   SENDPKT    ; Send 256 bytes.
99AD: E6 FD    >509           inc   address+1  ; Advance to next page
99AF: C6 FF    >510           dec   length+1   ;  and decrement page
99B1: D0 F1    >511           bne   :loop      ;   count until done...
99B3: A6 FE    >512  :short   ldx   length     ; Remaining data length.
99B5: F0 07    >513           beq   :done      ; -All done.
99B7: A5 FC    >514           lda   address    
99B9: A4 FD    >515           ldy   address+1  
99BB: 20 17 98 >516           jsr   SENDPKT    ; Send the final packet.
99BE: 60       >517  :done    rts              
 
                ===== Page 56 -  NADA.PRODOS - Nov. 17, 2004 =====
  
               >520  **********************************************************
               >521  *                                                        *
               >522  *                     R C V L O N G                      *
               >523  *                                                        *
               >524  *             Michael J. Mahon - May 5, 1996             *
               >525  *                                                        *
               >526  *                   Copyright (c) 1996                   *
               >527  *                                                        *
               >528  *  RCVLONG receives 'length' bytes to 'address' from the *
               >529  *  currently sending machine.                            *
               >530  *                                                        *
               >531  *  It receives a series of packets if 'length' is        *
               >532  *  greater than 256 bytes.                               *
               >533  *                                                        *
               >534  *  RCVLONG detects checksum errors and timeouts, and     *
               >535  *  returns with Carry set and A=0 if timeout, and        *
               >536  *  Carry set and A>0 if a checksum error.  Timeouts in   *
               >537  *  this context are protocol errors.  Both kinds of      *
               >538  *  errors are tallyed in counters.                       *
               >539  *                                                        *
               >540  **********************************************************
               >541  
99BF: A5 FF    >542  RCVLONG  lda   length+1   ; How many 256-byte pages?
99C1: F0 11    >543           beq   :short     ; - None, just a short pkt.
99C3: A2 00    >544  :loop    ldx   #0         ; Set 256 byte packet.
99C5: A5 FC    >545           lda   address    ;  and point to
99C7: A4 FD    >546           ldy   address+1  ;   data buffer.
99C9: 20 01 99 >547           jsr   RCVPKT     ; Receive 256 bytes.
99CC: B0 14    >548           bcs   :err       ; Receive error detected.
99CE: E6 FD    >549           inc   address+1  ; Advance to next page
99D0: C6 FF    >550           dec   length+1   ;  and decrement page
99D2: D0 EF    >551           bne   :loop      ;   count until done...
99D4: A6 FE    >552  :short   ldx   length     ; Remaining data length.
99D6: F0 09    >553           beq   :done      ; -All done.
99D8: A5 FC    >554           lda   address    
99DA: A4 FD    >555           ldy   address+1  
99DC: 20 01 99 >556           jsr   RCVPKT     ; Receive final packet.
99DF: B0 01    >557           bcs   :err       ; Keep track of any errors.
99E1: 60       >558  :done    rts              
               >559  
99E2: F0 0A    >560  :err     beq   :timeout   ; Split timeouts and cksum errs
               >561           inc16 ckerr      ; Tally check sum error.
99E4: EE 3D 91 >561           inc   ckerr      ; Increment 16-bit word.
99E7: D0 03    >561           bne   *+5        ; - No carry.
99E9: EE 3E 91 >561           inc   ckerr+1    ; Propagate carry.
               >561           eom              
99EC: A8       >562           tay              ; Clear Z flag (A <> 0)
99ED: 60       >563           rts              
               >564  
               >565  :timeout inc16 errprot    ; Tally protocol error.
99EE: EE 3B 91 >565           inc   errprot    ; Increment 16-bit word.
99F1: D0 03    >565           bne   *+5        ; - No carry.
99F3: EE 3C 91 >565           inc   errprot+1  ; Propagate carry.
               >565           eom              
99F6: A8       >566           tay              ; Set Z flag (A = 0)
99F7: 60       >567           rts              
 
                ===== Page 57 -  NADA.PRODOS - Nov. 17, 2004 =====
  
                58            align 256        ; Align to page boundary
99F8: 00 00 00  58            ds    *-1/256*256+256-* 
                58            eom              
                59   endcode  equ   *          
                60   pgmaplo  equ   endcode    ; First message buffer page
                61            err   *-1-entry/SIZE ; Can't exceed limit
 
 
--End assembly, 2304 bytes, Errors: 0 

Symbol table - alphabetical order:
   @       =$9126      ADDON   =$D998      AMPNADA =$9213      AMPVECT =$03F5
   ARBTRATE=$976A      AX      =$48        BOOTREQ =$9422      BPOKEREQ=$95A2
   BPOKESRV=$95C1      CALLREQ =$95D7      CALLSRV =$95EA      CALL_t  =$8C
   CHRGET  =$B1        CHRGOT  =$B7        ERROR   =$D412      FAC     =$9D
   FLO2    =$EBA0      FORPNT  =$85        FRMNUM  =$DD67      GETADR  =$E752
   GETBYT  =$E6F8      GETIDSRV=$946E      GETMREQ =$96DD      GET_t   =$BE
   INIT    =$935B      INSTALL =$91E6      INTFLG  =$12        MONITOR =$9715
   PEEKREQ =$94A0      PEEKSRV =$94E2      PEEK_t  =$E2        PKINCREQ=$9519
   PKINCSRV=$952C      POKEREQ =$954C      POKESRV =$957B      POKE_t  =$B9
   PTRGET  =$DFE3      PUTMREQ =$96AA   ?  PWREDUP =$03F4      RCVCTL  =$98FB
   RCVDACK =$966E      RCVLONG =$99BF      RCVPKT  =$9901      RCVPTR  =$9905
   REQUEST =$9600      ROMboot =$00        SENDACK =$9800      SENDCTL =$9811
   SENDLONG=$99A0      SENDPKT =$9817      SENDRSP =$9802      SERVER  =$9381
   SETFOR  =$EB27      SIZE    =$0900   ?  SOFTEV  =$03F2      SYNCHR  =$DEC0
   SYNERR  =$DEC9      TXTPTR  =$B8        VALTYP  =$11     ?  VBL     =$C019
V? ]PROTERR=$9417   V  ]cpx    =$0B     V  ]cpy    =$0B04   V  ]cy     =$4FB0
MV ]delay  =$9704   MV ]dly    =$9624   V  ]servpad=$FF        addr    =$46
   address =$FC        adr     =$04     MD align   =$8000      an      =$C058
?  an0     =$C058      an1     =$C05A   ?  an2     =$C05C   ?  an3     =$C05E
   arbtime =$01        arbx    =$5C        arbxv   =$9156      baddr   =$5A
   bleng   =$5C        blocadr =$5E        bootadr =$9140      bootcnt =$32
   bootcode=$9144      bootctr =$915C      bootdly =$03E8      bootflg =$915D
   bootlen =$9142      bootself=$03CC   ?  bpoke   =$911E      bufend  =$9000
   bufstrt =$2000      byte    =$00     ?  call    =$9115      chain   =$9229
   ckbyte  =$EC        ckerr   =$913D      class   =$46        cmd     =$9220
   cmdptr  =$EC        cmdsave =$ED        cmdtable=$9166      comp    =$922C
   crate   =$00        cyperms =$03FC   MD delay   =$8000      dest    =$04
   disp    =$EF     MD dlyms   =$8000      dos     =$00        drecv   =$C062
   dsend   =$C05A      dsk6off =$C0E8      dst     =$02        endcode =$9A00
   entry   =$9100      errprot =$913B      errstop =$9161      frm     =$03
   gapwait =$08        getidflg=$915E   ?  getmsg  =$911B      idletime=$14
   idleto  =$08        idtable =$9146      idtbl   =$933D   MD inc16   =$8000
   incr    =$48     ?  init    =$9109      instald =$915F      iter    =$19
   keybd   =$C000      len     =$06        lenctl  =$08        leng    =$EB
   length  =$FE        lngth   =$48        lngth?  =$D0        locaddr =$9138
   locadr  =$52        master  =$01     ?  maxarb  =$03        maxgap  =$65
   maxreq  =$0A        maxreqrt=$03        maxretry=$32        mod     =$01
?  monitor =$9124      monlen  =$08     MD mov16   =$8000      mserve  =$00
   n60ms   =$14        nadapage=$03CF      nparms  =$9160      null    =$933A
   parmsiz =$2F        pb      =$C061   ?  pb0     =$C061      pb1     =$C062
?  pb2     =$C063   ?  peek    =$910F   ?  peekinc =$9121   ?  pgmaplo =$9A00
?  poke    =$9112      ptr     =$ED     ?  ptrig   =$C070   ?  putmsg  =$9118
   px      =$FF        r_BOOT  =$07        r_BPOKE =$08        r_CALL  =$03
?  r_GETID =$06        r_GETMSG=$05        r_PEEK  =$01        r_PKINC =$09
   r_POKE  =$02        r_PUTMSG=$04        rbuf    =$9130      req     =$00
   reqctr  =$915B      reqdelay=$11        reqretry=$9159      reqtime =$0BB8
   reqto   =$01        retrycnt=$915A      retrylim=$913A      rm_ACK  =$02
   rm_DACK =$03        rm_NAK  =$04        rm_REQ  =$01        rqperiod=$14
   sbuf    =$9128      self    =$9127      sendck  =$9158   ?  serve   =$910C
   servecnt=$913F      servegap=$3A        servelp =$9103      service =$9349
   setid   =$9371   ?  spkr    =$C030      timeout =$9330      toflg1  =$DE
   toflg2  =$AD        tolim   =$9157      val     =$48        val?    =$D0
   var     =$80        varadr  =$9164      varcmd  =$9162      vartype =$9163
   warmstrt=$03CD      word    =$40        zipslow =$C0E8   

Symbol table - numerical order:
 
                ===== Page 58 -  NADA.PRODOS - Nov. 17, 2004 =====
 
   dos     =$00        crate   =$00        mserve  =$00        ROMboot =$00
   req     =$00        byte    =$00        master  =$01        arbtime =$01
   reqto   =$01        mod     =$01        r_PEEK  =$01        rm_REQ  =$01
   dst     =$02        r_POKE  =$02        rm_ACK  =$02     ?  maxarb  =$03
   maxreqrt=$03        frm     =$03        r_CALL  =$03        rm_DACK =$03
   adr     =$04        r_PUTMSG=$04        rm_NAK  =$04        dest    =$04
   r_GETMSG=$05        len     =$06     ?  r_GETID =$06        r_BOOT  =$07
   idleto  =$08        gapwait =$08        lenctl  =$08        r_BPOKE =$08
   monlen  =$08        r_PKINC =$09        maxreq  =$0A     V  ]cpx    =$0B
   reqdelay=$11        VALTYP  =$11        INTFLG  =$12        idletime=$14
   rqperiod=$14        n60ms   =$14        iter    =$19        parmsiz =$2F
   maxretry=$32        bootcnt =$32        servegap=$3A        word    =$40
   addr    =$46        class   =$46        lngth   =$48        AX      =$48
   incr    =$48        val     =$48        locadr  =$52        baddr   =$5A
   arbx    =$5C        bleng   =$5C        blocadr =$5E        maxgap  =$65
   var     =$80        FORPNT  =$85        CALL_t  =$8C        FAC     =$9D
   toflg2  =$AD        CHRGET  =$B1        CHRGOT  =$B7        TXTPTR  =$B8
   POKE_t  =$B9        GET_t   =$BE        lngth?  =$D0        val?    =$D0
   toflg1  =$DE        PEEK_t  =$E2        leng    =$EB        ckbyte  =$EC
   cmdptr  =$EC        ptr     =$ED        cmdsave =$ED        disp    =$EF
   address =$FC        length  =$FE        px      =$FF     V  ]servpad=$FF
   bootself=$03CC      warmstrt=$03CD      nadapage=$03CF      bootdly =$03E8
?  SOFTEV  =$03F2   ?  PWREDUP =$03F4      AMPVECT =$03F5      cyperms =$03FC
   SIZE    =$0900   V  ]cpy    =$0B04      reqtime =$0BB8      bufstrt =$2000
V  ]cy     =$4FB0      bufend  =$9000      entry   =$9100      servelp =$9103
?  init    =$9109   ?  serve   =$910C   ?  peek    =$910F   ?  poke    =$9112
?  call    =$9115   ?  putmsg  =$9118   ?  getmsg  =$911B   ?  bpoke   =$911E
?  peekinc =$9121   ?  monitor =$9124      @       =$9126      self    =$9127
   sbuf    =$9128      rbuf    =$9130      locaddr =$9138      retrylim=$913A
   errprot =$913B      ckerr   =$913D      servecnt=$913F      bootadr =$9140
   bootlen =$9142      bootcode=$9144      idtable =$9146      arbxv   =$9156
   tolim   =$9157      sendck  =$9158      reqretry=$9159      retrycnt=$915A
   reqctr  =$915B      bootctr =$915C      bootflg =$915D      getidflg=$915E
   instald =$915F      nparms  =$9160      errstop =$9161      varcmd  =$9162
   vartype =$9163      varadr  =$9164      cmdtable=$9166      INSTALL =$91E6
   AMPNADA =$9213      cmd     =$9220      chain   =$9229      comp    =$922C
   timeout =$9330      null    =$933A      idtbl   =$933D      service =$9349
   INIT    =$935B      setid   =$9371      SERVER  =$9381   V? ]PROTERR=$9417
   BOOTREQ =$9422      GETIDSRV=$946E      PEEKREQ =$94A0      PEEKSRV =$94E2
   PKINCREQ=$9519      PKINCSRV=$952C      POKEREQ =$954C      POKESRV =$957B
   BPOKEREQ=$95A2      BPOKESRV=$95C1      CALLREQ =$95D7      CALLSRV =$95EA
   REQUEST =$9600   MV ]dly    =$9624      RCVDACK =$966E      PUTMREQ =$96AA
   GETMREQ =$96DD   MV ]delay  =$9704      MONITOR =$9715      ARBTRATE=$976A
   SENDACK =$9800      SENDRSP =$9802      SENDCTL =$9811      SENDPKT =$9817
   RCVCTL  =$98FB      RCVPKT  =$9901      RCVPTR  =$9905      SENDLONG=$99A0
   RCVLONG =$99BF      endcode =$9A00   ?  pgmaplo =$9A00   MD align   =$8000
MD dlyms   =$8000   MD delay   =$8000   MD mov16   =$8000   MD inc16   =$8000
   keybd   =$C000   ?  VBL     =$C019   ?  spkr    =$C030      an      =$C058
?  an0     =$C058      an1     =$C05A      dsend   =$C05A   ?  an2     =$C05C
?  an3     =$C05E      pb      =$C061   ?  pb0     =$C061      pb1     =$C062
   drecv   =$C062   ?  pb2     =$C063   ?  ptrig   =$C070      dsk6off =$C0E8
   zipslow =$C0E8      ERROR   =$D412      ADDON   =$D998      FRMNUM  =$DD67
   SYNCHR  =$DEC0      SYNERR  =$DEC9      PTRGET  =$DFE3      GETBYT  =$E6F8
   GETADR  =$E752      SETFOR  =$EB27      FLO2    =$EBA0   